Support

Account

Home Forums Front-end Issues Categories not displaying after last update

Unread

Categories not displaying after last update

  • Super weird, was working up until last ACF update. Any ideas what I’m missing? This line is the culprit: $categories = get_the_terms( $post->ID, ‘taxonomy’ );

    Error thrown is “Notice: Trying to get property of non-object Relationship field”

    <?php
    /* FIRST
     * Note: This function only returns results from the default “category” taxonomy. For custom taxonomies use get_the_terms().
     */
    $categories = get_the_terms( $post->ID, 'taxonomy' );
    // now you can view your category in array:
    // using var_dump( $categories );
    // or you can take all with foreach:
    foreach( $categories as $category ) {
        echo $category->term_id . ', ' . $category->slug . ', ' . $category->name . '<br />';
    }
Viewing 1 post (of 1 total)

The topic ‘Categories not displaying after last update’ is closed to new replies.