• I’ve tried:

    get_cat_name( $id );

    and

    $id = get_query_var(‘cat’);

    both return my the Post ID of an entry, not its originating Category like I need.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Where are you dong this?

    Thread Starter NoahRodenbeek

    (@noahrodenbeek)

    Here: http://verymintcomics.com

    I’m echoing the $id below the comic, in the Navigation bar, it’s being displayed right before the “PREVIOUS” link, see?

    If you jump to other comics you can see how it’s displaying the post’s ID instead of its Category.

    Thanks for the reply! I really need help with this.

    Thread Starter NoahRodenbeek

    (@noahrodenbeek)

    <?php
    get_cat_name( $id );
    echo $id;
    $posts = get_posts(array(‘category’ => $id));
    print_r($posts);
    ?>

    That’s everything that’s going on, so that “Array[]” that’s being displayed is an empty array as result of the second get_ failing

    Thread Starter NoahRodenbeek

    (@noahrodenbeek)

    Nevermind I figured it out finally:

    <

    ?php
    $id = get_the_category();
    $cat_id = $id[0]->cat_ID;
    //echo $cat_id;

    //get array of Posts for Category, default is ‘order by date’, set it to Ascending instead of default Descending
    $args = array( ‘category’ => $cat_id, ‘order’ => ‘ASC’ );
    $posts = get_posts( $args );
    //echo $posts[0]->guid;

    //display

    • link that jumps to first item in Posts Array
      $link = $posts[0]->guid;
      echo ‘FIRST‘;
      ?>
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Method to Identify Category Returns Post ID Instead, :(’ is closed to new replies.