• 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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter hutton001

    (@hutton001)

    this is code sidebar.php
    https://pastebin.com/ppxss98E

    I use the widget in siderb

    what widget?

    are you calling this function in the sidebar widget?

    Thread Starter hutton001

    (@hutton001)

    nope… this function is calling out the widget, but nothing is displayed

    Thread Starter hutton001

    (@hutton001)

    Sorry… i have found the problem..
    in the function i calling global $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.

    Thread Starter hutton001

    (@hutton001)

    i delete widget in sidebar and used function in un normal tag div external the if conditional.
    Now i see the list category: https://test.bricevimenti.com/

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘List categories with description’ is closed to new replies.