List categories with description
-
Hi, little problem… i need see a list of categories with title and description but dont see count article for categories. I use the widget in siderbar and i create this function:
function viewCategories() { global $post; $args=array( 'orderby' => 'name', 'order' => 'ASC' ); $categories=get_categories($args); foreach($categories as $category) { echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a></p> '; echo '<p> Description:'. $category->description . '</p>'; //echo '<p> Post Count: '. $category->count . '</p>'; } }the problem is that the output does not change anything.
-
this is code sidebar.php
http://pastebin.com/ppxss98EI use the widget in siderb
what widget?
are you calling this function in the sidebar widget?
nope… this function is calling out the widget, but nothing is displayed
Sorry… i have found the problem..
in the function i callingglobal $post;and this created an error.the code seems to be ok;
do you have any catgories in your site?
does the ‘normal’ category widget show any categories?is the code of your function saved in functions.php of your theme?
any error messages?are there more than one sidebar files in your theme?
i.e. is the sidebar-1 shown on your site?is the div
<div id="widget-category">appearing in the html of your site?try to see if any static text at the beginning of line 19 of your pastebin would get shown in the sidebar.
i delete widget in sidebar and used function in un normal tag
divexternal theifconditional.
Now i see the list category: http://test.bricevimenti.com/
The topic ‘List categories with description’ is closed to new replies.