WordPress.org

Support

Support » Themes and Templates » Minimatica » Theme's posts per page query filter is also filtering plugin queries

Theme's posts per page query filter is also filtering plugin queries

  • Hi Daniel, a user of my plugin Meteor Slides ran into an issue using it with your theme Minimatica. The quantity of the Meteor Slides slideshows was stuck on 4, regardless of what quantity was set in the plugin settings.

    I took a look and found the function in functions.php that was causing the problem:

    function minimatica_paged_posts( $query ) {
    	if( (
    		( $query->is_home() && 'gallery' == minimatica_get_option( 'homepage_view' ) ) ||
    		( $query->is_category() && 'gallery' == minimatica_get_option( 'category_view' ) ) ||
    		( $query->is_tag() && 'gallery' == minimatica_get_option( 'tag_view' ) ) ||
    		( $query->is_author() && 'gallery' == minimatica_get_option( 'author_view' ) ) ||
    		( $query->is_archive() && 'gallery' == minimatica_get_option( 'archive_view' ) )
    		) && ( ! is_single() )
    	)
    		$query->set( 'posts_per_page', '4' );
    }

    This query filter is effecting all queries on the page, including the slideshow query.

    I updated it to check if the query is the main query, so it doesn’t get applied to new custom queries and that seemed to do the trick:

    function minimatica_paged_posts( $query ) {
    	if( (
    		( $query->is_main_query() && $query->is_home() && 'gallery' == minimatica_get_option( 'homepage_view' ) ) ||
    		( $query->is_main_query() && $query->is_category() && 'gallery' == minimatica_get_option( 'category_view' ) ) ||
    		( $query->is_main_query() && $query->is_tag() && 'gallery' == minimatica_get_option( 'tag_view' ) ) ||
    		( $query->is_main_query() && $query->is_author() && 'gallery' == minimatica_get_option( 'author_view' ) ) ||
    		( $query->is_main_query() && $query->is_archive() && 'gallery' == minimatica_get_option( 'archive_view' ) )
    		) && ( ! is_single() )
    	)
    		$query->set( 'posts_per_page', '4' );
    }
  • The topic ‘Theme's posts per page query filter is also filtering plugin queries’ is closed to new replies.
Skip to toolbar