• Resolved Ashley Michèlle

    (@ashleymichelle)


    I am using custom page templates on my site: https://ohmybonbon.com

    What I am looking to do, is to implement a sting of code that list only the subcategories from a specified parent category.

    For example:

    beauty.php template calls category “Beauty”, list all posts from that category.
    (https://ohmybonbon.com/beauty/)

    Above the posts, I simply want to list a menu showing the subcategories/children of “Beauty”.

    Here is an example of what I want to achieve (where it says “FOTD TUTORIALS SKINCARE MAKEUP HAIR”): Photo Example

    Any help on this would be immensely appreciated!

Viewing 1 replies (of 1 total)
  • Thread Starter Ashley Michèlle

    (@ashleymichelle)

    Never mind! I guess lack of sleep had gotten to my brain.

    For anyone else who is curious on how to do this, simply insert this code into your page template:

    <ul>
          <?php
    $categories = wp_list_categories('echo=0&title_li=0&child_of=2');
    $categories = preg_replace('/title=\"(.*?)\"/','',$categories);
    echo $categories;
    ?>
        </ul>
Viewing 1 replies (of 1 total)
  • The topic ‘List only subcategories from specific category on custom page template.’ is closed to new replies.