WordPress.org

Ready to get started?Download WordPress

Forums

Minimatica
Theme's posts per page query filter is also filtering plugin queries (1 post)

  1. Josh Leuze
    Member
    Posted 1 year ago #

    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' );
    }

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags

No tags yet.