Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › ASC order is not correct
This topic contains 17 replies, has 2 voices, and was last updated by kokosan 1 year, 3 months ago.
- AuthorPosts
- January 9, 2023 at 10:06 am #40817
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.
January 9, 2023 at 2:34 pm #40822You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 9, 2023 at 3:04 pm #40824You cannot access this content.January 9, 2023 at 3:15 pm #40826For 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.
January 9, 2023 at 4:57 pm #40831Thank you!
So, the plugin is set to display the items by creation (publish) date ascending.
Best,
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.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 10, 2023 at 3:40 am #40834Strange 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.
January 10, 2023 at 3:56 am #40835I 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
January 10, 2023 at 4:35 am #40836I 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.
January 10, 2023 at 10:47 am #40837Okay, 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 :)
January 10, 2023 at 10:53 am #40839I 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.
January 10, 2023 at 10:55 am #40840That 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.
Best,
You want ordering by ID, not date. Try the custom code, it will do the trick 🙂
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 10, 2023 at 11:09 am #40841Ok, 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
January 10, 2023 at 11:20 am #40842In 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 :)
January 10, 2023 at 11:29 am #40843I 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.
January 10, 2023 at 1:11 pm #40844The 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.
Best,
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
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.