Forums Forums Search & Filter Pro Duplicate search results

Tagged: 

Viewing 8 posts - 11 through 18 (of 18 total)
  • Trevor
    #175427
    This reply has been marked as private.
    Anonymous
    #175436
    This reply has been marked as private.
    Trevor
    #175557
    This reply has been marked as private.
    Anonymous
    #175651
    This reply has been marked as private.
    Anonymous
    #176462
    This reply has been marked as private.
    Ross Moderator
    #176557
    This reply has been marked as private.
    Ross Moderator
    #176753

    Hi David

    I’ve had another look into this, and I have some feedback.

    First, you should be able to resolve your issue by setting a secondary sort option in the posts tab of your search form 🙂

    Second, to explain how this works (if you’re interested):

    A lot of your posts, while sharing a publish date, also share the exact same publish time (I guess these were added programatically in some way, or their publish date/time was modified somehow).

    Just to clarify, if you don’t choose a sort order, WP default is by date, which is why I mention the identical dates.

    Anyway, there seems to be a little quirk in WP WP_Query class, or perhaps in the SQL itself – which meant that simply changing pagination in the exact exact same query, meant the posts were ordered in a different way, after being ordered by date first.

    To demonstrate, I created a WP query, which specified which post IDs I wanted (the twenty from the examples we’ve been using, your IDs may be different but I did import your classes post type locally)

    <?php
    	$args = array(
    		'post_type' => 'classes',
    		'paged' => '1',
    		'posts_per_page' => '12',
    		'post_status' => array('publish'),
    		'post_type' => 'classes',
    		'orderby' => array("post_date" => "DESC"),
    		'post__in' => array(9111,9117,9121,9143,9144,9145,9146,9147,9148,9149,9150,9151,9152,9328,9347,9359,9360,9363,9365,9366) //,
    	);
    	
    	$query = new WP_Query($args);
    	
    	$results = $query->get_posts();
    
    	foreach ($results as $post) {
    		//var_dump($post);
    		echo "{$post->ID} | {$post->post_title}<hr />";
    	}
    ?>

    Of course the issue is when 2 or more posts share identical publish dates/times, what order do they appear in?

    If you run this test and change pagination to 2, you will see the exact issue you have been experiencing – where the secondary sorting is inconsistent when changing pagination..

    Therefor the solution is that if we specify a secondary sort option, we control the consistency of the order.

    Anyway, hope all that helps!

    Thanks

    Anonymous
    #176758

    Ross this is awesome and I appreciate the detailed explanation. Many posts were indeed imported programmatically and the unique publish dates must not have been brought order. Secondary sorting by title is doing the trick.

    Thanks again for troubleshooting.

Viewing 8 posts - 11 through 18 (of 18 total)