Forums

List categories with description (7 posts)

  1. hutton001
    Member
    Posted 1 year ago #

    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.

  2. hutton001
    Member
    Posted 1 year ago #

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

  3. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    I use the widget in siderb

    what widget?

    are you calling this function in the sidebar widget?

  4. hutton001
    Member
    Posted 1 year ago #

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

  5. hutton001
    Member
    Posted 1 year ago #

    Sorry... i have found the problem..
    in the function i calling global $post; and this created an error.

  6. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    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.

  7. hutton001
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic