Categories List on Page

Discussion in 'WordPress' started by TrinityZey, Mar 27, 2011.

  1. #1
    I want to pull the list of the categories on my site on a single page, is there an easy way to do it?
     
    TrinityZey, Mar 27, 2011 IP
  2. mmm555

    mmm555 Member

    Messages:
    662
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    48
    #2
    I think there is an extension that does this... just do some creative searches to try and find it. Good luck. :)
     
    mmm555, Mar 27, 2011 IP
  3. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Add this to functions.php in your theme folder:
    
    function show_all_categories() {
    	$categories = get_categories();
    	foreach($categories as $category) { 
    		echo '<p><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a></p>';
    	}
    }
    
    add_shortcode('showallcats', 'show_all_categories');
    
    Code (markup):
    But this is even simpler:
    
    function show_all_categories() {
    	echo wp_list_categories('title_li=');
    }
    add_shortcode('showallcats', 'show_all_categories');
    
    Code (markup):
    Then create a post or page and add the shortcode [showallcats] to it.
     
    Last edited: Mar 28, 2011
    Cash Nebula, Mar 28, 2011 IP
  4. MeBloggs

    MeBloggs Peon

    Messages:
    159
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ^Great use of shortcode.
     
    MeBloggs, Mar 28, 2011 IP
  5. TrinityZey

    TrinityZey Well-Known Member

    Messages:
    258
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    103
    #5
    Awesome, that worked nicely :)
     
    TrinityZey, Mar 28, 2011 IP
  6. seoexpertcertification

    seoexpertcertification Greenhorn

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #6
    Use WP Category plugin.
     
    seoexpertcertification, Apr 3, 2011 IP