• Hello,

    I’m looking to
    – show the categories a post belongs to,
    – show those categories in a list
    – order those categories by ID
    – show only the categories with a certain parent

    It would be soooo great to make this a shortcode…

    This is what I found

    <?php
    foreach((get_the_category()) as $childcat) {
    if (cat_is_ancestor_of(16, $childcat)) {
    echo '<li class="<?php echo $orderby=ID;?>"><a href="'.get_category_link($childcat->cat_ID).'">';echo $childcat->cat_name . '</a></li>';
    }}
    ?>

    This code does :
    – show the categories a post belongs to
    – makes a list
    – shows only categories in parent ID (in this case 16)

    Still looking for some help to :
    – order those categories by ID
    – turn this into a shortcode

    Any suggestions are very welcome!

    Kind regards

  • The topic ‘list categories along with their post’ is closed to new replies.