Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1404649

    Dear Support-Team,

    I am wondering if I could filter the query for tag archives. I am using this code for the masonry element:

    function avia_masonry_custom_query( $query ) {
    	unset($query['post_type']['ABC']); // Custom Post Type "ABC"
    	$exclude_cat = array('category__not_in' => array( 1, 2 )); // Categories by ID
    	$query = array_merge((array)$exclude_cat, (array)$query);		
    	return $query;
    }
    add_filter('avia_masonry_entries_query', 'avia_masonry_custom_query');

    Is there a filter for the blog post element or even tag archives too? I have a certain tag archive with posts from different post types and I would like to strip all posts from one of the post types from the archive.

    Any ideas?

    All the best, Daniel

    #1405601

    Any advice on how to implement a filter for tag archives (see above)? I have a certain tag archive with posts from different post types and I would like to strip all posts from one of the post types from the archive.

    #1405785

    Hi,

    Sorry for the late reply.

    To modify the main query for archive you can use the pre_get_posts filter. An example how we use it to modify the search query is here:

    https://github.com/KriesiMedia/enfold-library/blob/master/actions%20and%20filters/Search/pre_get_posts.php

    For the ALB blog element we have the filter avia_blog_post_query.

    Hope this helps you.

    Best regards,
    Günter

    #1405788

    Hey Günter,

    thank you for getting back to me and thanks for the code snippet.

    So instead of if( $query->is_search ) I would somehow check if it is a certain post type archive instead of is_search – correct? The rest of the code is the same? Could I write something like if( $query->is_tax('test') and later on define which post type is the only one to query in this archive?

    Best regards,
    Daniel

    #1405803

    Hi,

    Definition of is_tax():

    I would say yes, this should be the way (but I did not test it).

    Best regards,
    Günter

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