• I’m using Zoomfolio plugin and this creates a Portfolio custom post type. I’ve added portfolio posts and assigned portfolio categories but I can’t seem to echo the assigned categories when on the single portfolio post view.

    I’ve tried various things and they all return empty results. I’m echoing the post ID so I know that exists and I’ve tried inside and outside the loop.

    $post_categories = wp_get_post_categories($post->ID);
    $terms = wp_get_post_terms($post->ID,’dzs_portfolio’);

    How can I best debug the problem? Is there a way I can echo all the data for a post to check it has the categories assigned? Thanks,

Viewing 1 replies (of 1 total)
  • Thread Starter benners_

    (@benners_)

    Would be nice to know why the standard APIs don’t work but I got what I need with this.

    $categories = $wpdb->get_row("SELECT wp_terms.name, wp_terms.slug FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_terms ON (wp_term_relationships.term_taxonomy_id = wp_terms.term_id) WHERE wp_posts.ID = ".$post->ID, ARRAY_N);
    
    if($categories){
        $get_my_cats = '';
        foreach($categories as $key => $value ) {
            if($key  == 'name') {
                $get_my_cats .= "<li>".$value."</li>";
            }
        }
        $get_my_cats = "<ul>".$get_my_cats."</ul>";
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Can't get categories assigned to a custom post type’ is closed to new replies.