WordPress.org

Ready to get started?Download WordPress

Forums

using get_the_category to go one more level in depth of current post (1 post)

  1. espnicholas
    Member
    Posted 2 years ago #

    What I'm attempting to do is to get the current code or one like it:

    <?php
    foreach((get_the_category()) as $category) {
        if ($category->category_parent  == '7') {
            echo '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf(__( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> ';
        }
    }
    ?>

    It will display the post under the current category chosen, so say ID 42 = Places and it will output the child USA

    I'm trying to go further in the category depths to pull the next category inline, such as it is setup:

    Places (id 42), USA, Florida, City

    The current code will grab only the child of 42, how do I make it retrieve one depth lower to get just Florida and not the City?

Topic Closed

This topic has been closed to new replies.

About this Topic