WordPress.org

Ready to get started?Download WordPress

Forums

Using get_categories Shows Multiple Of The Same Category (4 posts)

  1. knowyourmac
    Member
    Posted 4 years ago #

    I just finished using the get_categories function in the sidebar, and it looks like this:

    <h4>Categories</h4>
    <ul>
    <?php
    	$args = array(
    		'type' => 'post'
    	);
    	$categories = get_categories($args);
    	foreach ($categories as $cat) {
    		$option .= '<li><a href="/category/';
    		$option .= $cat->cat_name;
    		$option .= '">';
    		$option .= $cat->cat_name;
    		$option .= '</a></li>';
    		echo $option;
    	}
    ?>
    </ul>

    It works and all, but shows multiple of the same category. Take a look: http://www.ju1c3.com

    Anyone know why?

  2. knowyourmac
    Member
    Posted 4 years ago #

    Anyone?

  3. WebTechGlobal
    Member
    Posted 4 years ago #

    So are you now finding $categories = get_categories($args);
    works ok for you? I'm not, it does not return child cats that it should when passed an ID for the parent.

    Just wondered if this function is totally messed up as theres a lot of recent talk about it since 2.8 release.

  4. relish1227
    Member
    Posted 4 years ago #

    I'm having the same issue.

Topic Closed

This topic has been closed to new replies.

About this Topic