• Resolved yaphi

    (@yaphi)


    I am trying to list all the categories on my archives page (so not in the loop) and I am no PHP person. I tried this:

    <?php
    	foreach((get_the_category()) as $category) {
    		echo '<li><a href="/topics/' . $category->category_nicename . '">' . $category->cat_name . '</a><span class="amount" style="width:"' . $category->category_count . 'px"">&nbsp;</span></li>';
    	}
    ?>

    but that only listed one category so then I read a bunch and decided I needed to probably write SQl outright so I tried this.

    $categories = mysql_query("SELECT term_id FROM terms ORDER BY ID");
    for($i=1;$i<($categories[$i]);$i++){
    	echo '<li><a href="/topics/' . $category[$i]->category_nicename . '">' . $category->cat_name . '</a><span class="amount" style="width:' . $category->category_count . 'px">&nbsp;</span></li>';
    }

    That doesn’t do anything. I am just guessing here cause I have no idea with php. Can someone help me achieve what I want? I want the result of the first code sample but all the categories, not just one.

  • The topic ‘Help with custom category listing’ is closed to new replies.