Avada Forums Community Forum Post Card – How to filter

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • R4YB
    Participant
    Post count: 2

    Hi!
    I have two types of PostType, “club” and “athlete”.
    The athlete element has a link to his club with ACF PRO.
    The club have “city” as its taxonomy.
    I have created a post card layout to apply to “archive-athlete.php” and one for “archive-club.php”
    I have taxonomy-city-term_slug.php *
    How can I filter the post card?

    I wanto to see for example
    “the athlete belonging to this club” of
    “club in this city (without displaying athletes from that city)”

    I have tried using code, but the postcard seems to overwrite the queries completely…

    I don’t think that this problem is a customization. I think that problem is a bug.

    Wordpress ask developers to NOT override global wp_query, but I think’s that Post card do something like that, just because I can’t use “pre_get_posts” wordpress hook to “alter” current query.

    Can anyonehelp me?

    SeanP
    Participant
    Post count: 4

    Any Luck with this? I’m having the exact same issues.

    yewsau
    Participant
    Post count: 2

    Did any of you get any solution for this?

    Ammar. S
    Keymaster
    Post count: 2227

    Hello Everyone

    In our next major update, we have already added an option to filter directly from the postcard element, this will make things easier in such specific scenario, another option for combined filtration is also in works and will be out soon 🙂

    Thanks

    -Ammar

    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 );
    peshmerge
    Participant
    Post count: 2

    When is the next major update?

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.