Home › Forums › General Issues › Getting Field Value of A Different CPT through Relationship with WP_Query › Reply To: Getting Field Value of A Different CPT through Relationship with WP_Query
function solution_directory( $query ) {
if ( $query->is_main_query() && !$query->is_feed() && !is_admin() && $query->is_post_type_archive( 'solution' ) ) {
$meta_query = array(
array(
'key' => 'sponsored',
'value' => 'yes',
'compare' => 'IN'
)
);
$query->set( 'meta_query', $meta_query );
$query->set( 'orderby', 'meta_value' );
$query->set( 'meta_key', 'sponsored' );
$query->set( 'order', 'ASC' );
$query->set( 'posts_per_page', '4' );
$query->set( 'facetwp', 'true' );
}
}
add_action( 'pre_get_posts', 'solution_directory' );
I’m trying this sort of thing, but I know that I’m not reaching the sponsored
field through the relationship with this.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.