• Resolved haero_canada

    (@haero_canada)


    Hi everyone,

    I had the best solution to my question, but unfortunately I played with my sidebar last night, and somehow deleted the widget content, so I can’t recall where did I take the php snippet from. Anyways, what I am trying to do is simply call specific categories (I remember that I input their id numbers, separated by comma) to show in unordered list. I managed to find a cached copy of my sidebar before I screwed it up. I made a snapshot – take a look here – https://www.radevtrade.com/Category.jpg

    So as you can see, at the back – the little brackets it shows how many post are contained per category. Basically once people click on the category – it takes them to the category permalink, where people can see all the posts. Anyone have the snippet in their pocket ?? I would be veery very thankful if you can help me out with that!

    Thanks guys

    Regards.

Viewing 1 replies (of 1 total)
  • Thread Starter haero_canada

    (@haero_canada)

    RESOLVED!!! Luckily I just remembered that I used the same snippet on another website of mine – so I just copied it from there ?? so happy!
    Being always keen to share, here is the magical snippet I was looking for, in case some else wants to use it:

    <?php
    wp_list_categories(‘show_count=1&include=4,15,14,13&title_li=’); ?>

    <?php
    // Grab the categories – top level only (depth=1)
    $get_cats = wp_list_categories( ‘echo=0&title_li=&depth=1’ );
    // Split into array items
    $cat_array = explode(”,$get_cats);
    // Amount of categories (count of items in array)
    $results_total = count($cat_array);
    // How many categories to show per list (round up total divided by 3)
    $cats_per_list = ceil($results_total / 3);
    // Counter number for tagging onto each list
    $list_number = 1;
    // Set the category result counter to zero
    $result_number = 0;
    ?>

    Take care

Viewing 1 replies (of 1 total)
  • The topic ‘How to display specific wp categories in unordered list’ is closed to new replies.