• delgado2009

    (@delgado2009)


    Hello everyone, I want to display on index the category name of posts with an custom query like this:

    <?$pop = $wpdb->get_results(“SELECT id, post_title, comment_count FROM {$wpdb->prefix}posts WHERE post_type=’post’ ORDER BY comment_count DESC LIMIT 6”);

    foreach($pop as $post) : ?>
    Category: <?php
    $category = get_the_category();
    $cat = $category[‘$id’];
    foreach ( $cat as $key => $value )
    echo $value;?>

    Any idea?

  • The topic ‘Retrieve the list of categories for a post with custom query’ is closed to new replies.