ASC order is not correct

This topic contains 17 replies, has 2 voices, and was last updated by kokosan kokosan 1 year, 3 months ago.

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #40817
    kokosan
    kokosan
    Participant

    Hi, I quey posts and display them in an ASC order (‘order’ => ‘ASC’), and it display correctly like this:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33

    Howoever, in the result, it doesn’t. The order looks like this:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    11
    10
    13
    14
    15
    16
    17
    18
    19
    20
    21
    12
    23
    24
    25
    26
    27
    28
    29
    30
    31
    22
    33

    Look at the number 10,11, 12, 22, etc. which are not in the correct order. In Source settings > order. I choose “Date ascending” and Limit is 10 per page.

    • This topic was modified 1 year, 3 months ago by kokosan kokosan.
    #40822
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #40824
    kokosan
    kokosan
    Participant
    You cannot access this content.
    #40826
    kokosan
    kokosan
    Participant

    For example after page number 9 (post 9) it should be 10. but 11, etc. If you want to check the search instance, it’s the first one.

    #40831
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thank you!

    So, the plugin is set to display the items by creation (publish) date ascending.
    When I check the posts by creation date (on the site back-end), I am seeing the same order: https://i.imgur.com/tCL5Lxk.png
    The ordering displayed by the plugin is correct, the creation dates are incorrectly set on the actual posts.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #40834
    kokosan
    kokosan
    Participant

    Strange to me, I use custom query to display post with ‘order’ => ‘ASC’ and it displays correctly. After 9 and it’s 10 not 11. If the creation dates are incorrectly set on the actual posts, the order in the custom query woudl not incorrect also.

    #40835
    kokosan
    kokosan
    Participant

    I use WOLF bulk editor. In its dashboard, it dispplays in an ASC order correctly https://drive.google.com/file/d/1hw1zxuYqnwGlQSTolYnAJ7GZFNtyr-2W/view?usp=sharing

    #40836
    kokosan
    kokosan
    Participant

    I create posts in order by importing CSV. Each post is arranged in order on the Excel row. Every post has page numner, which indicates the order correctly.

    #40837
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Okay, I see the issue now – the ordering there is not by date, but by ID.

    To force an ordering by ID, then you may need a bit of custom code. Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    add_filter("asp_query_args", "asp_order_by_id", 10, 2);
    function asp_order_by_id($args, $search_id) {
    	$args['post_primary_order'] = "id ASC";
    	return $args;
    }

    This will do the trick.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #40839
    kokosan
    kokosan
    Participant

    I also try this plugin Essential Grid, which is one of the most popular that has filter and ASC order like your plugin. It also has shortcode to display posts like your plugin. With this plugin, it displays posts in ASC order correctly. After 9, it’s 10, 11, etc. You can check this in the home page, just hover your mouse on the grids.

    #40840
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    That is, as I explained, a different ordering, not by date. The date ordering is the same as on the screenshot I sent you from the post editor. If you check the dates and times, you can see that is actually correct.
    You want ordering by ID, not date. Try the custom code, it will do the trick 🙂

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #40841
    kokosan
    kokosan
    Participant

    Ok, will try your code and take sometime to check and confirm. But let me add something, in Essentail Grid I also choose order by date, not by ID, But still it shows correctly (even not order by id) https://drive.google.com/file/d/1PN3MNZRIOeHurR3zLz3d4Qu00ts4xDAc/view?usp=sharing

    #40842
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    In that case, they either use the “modified date” or another field for the date.

    The post editor screen ordering is definitely correct, which is the same output as you got from ajax search pro. That is the correct ordering for the published date, otherwise it would be different on the post editor screen, which is definitely correct – as it is the core WordPress feature.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #40843
    kokosan
    kokosan
    Participant

    I still don’t understand why in the post editor it’s not in the correct order while custom query and other filter plugins do. I plan and create posts in order, per page with per page number. But it’s not in correct order in post editor.

    #40844
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    The post editor is the correct order for the native date field – the other plugins are not, if the ordering is different for them. Sometimes developers use the post “ID” field for the ordering by date, and that may cause the difference. It is also possible, that they use different fields or there is a hook to change the ordering of the field, which does not apply to the back-end editor. It is not neccessary a mistake, sometimes it is intentional. It is almost impossible to tell without knowing the actual plugin code.
    Even if you look at one of the screenshots you sent, if you check the columns, here the posts are ordered by the IDs: https://i.imgur.com/d5w9n4R.png

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 15 posts - 1 through 15 (of 18 total)

You must be logged in to reply to this topic.