WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] returnin category properties (id, link, etc) (3 posts)

  1. leogermani
    Member
    Posted 7 years ago #

    Hi,

    Ive tried hard to get this... but Im not beeing able to do something I beleive should be simple...

    All I want is to retrieve the parent category link of the current post inside The Loop.

    I want to do this: "AUTHORs NAME

    My last try to get the category id was:

    <blackticks>

    <? global $id ?>
    <?php $query = "

    SELECT category_id

    FROM $wpdb->post2cat

    WHERE post_id = $id ";

    $categoria = $wpdb->get_results($query);
    echo $categoria->category_id;

    ?>
    </blackticks>

    I returns nothing...

    any help?

  2. leogermani
    Member
    Posted 7 years ago #

    oops

    correcting one line of the post above:

    I want to do this: a href="CATEGORY_LINK" > AUTHORS NAME /a

  3. leogermani
    Member
    Posted 7 years ago #

    I managed it:

    $cat = get_the_category();
    echo $cat[0]->cat_ID;

Topic Closed

This topic has been closed to new replies.

About this Topic