Avada Forums Community Forum Post Card – How to filter Reply To: Post Card – How to filter

nhwebsites
Participant
Post count: 5

Something like this should do:

function set_custom_filters($query)
{
	if (get_post_type()==='club'){
		if ( ! is_admin() &&  array_key_exists('post_type', $query->query) ){
			if ($query->query['post_type']==='athlete' && !$query->get('tax_query')){
				$athletesinclub = get_post_meta(get_the_ID(), 'athlete');
				$query->set( 'post__in', $athletesinclub [0] );
			}
		}
	}
}
add_action( 'pre_get_posts', 'set_custom_filters', 20 );
  • This reply was modified 1 month, 1 week ago by nhwebsites.