Support

Account

Home Forums Add-ons Repeater Field ACF Query Post Object in Repeater matching the Custom post

Unread

ACF Query Post Object in Repeater matching the Custom post

  • Is it possible to use the below meta query with a post object field inside a repeater?

    $related_articles = get_posts(array(
        'post_type' => 'post',
        'meta_query' => array(
            array(
                'key' => 'related_articles', // name of custom field
                'value' => '"' . get_the_ID() . '"',
                'compare' => 'LIKE'
            )
        )
    ));
    
    if( $related_articles ): 
        foreach( $related_articles as $article ): 
    
        // Do something to display the articles. Each article is a WP_Post object.
        // Example:
    
        echo $article->post_title;  // The post title
        echo $article->post_excerpt;  // The excerpt
        echo get_the_post_thumbnail( $article->ID );  // The thumbnail
    
        endforeach;
    endif;
Viewing 1 post (of 1 total)

The topic ‘ACF Query Post Object in Repeater matching the Custom post’ is closed to new replies.