Skip Navigation

[Resolved] Custom post order

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 9 replies, has 3 voices.

Last updated by Minesh 12 months ago.

Assisted by: Minesh.

Author
Posts
#2669167

I have post types created with Toolset.

The default WordPress Posts post type are listed in wp-admin All Posts with the newest post first by default.

This is perfect.

But the post types we've created with Toolset (e.g. 'Resources" post type) they're listed alphabetically by default.

I know that I can reorder every time I load the page, but is there any way to have them listed by newest post first be default please?

Note that this is specifically about the display of All Posts in wp-admin, not the display of posts on the front end of the website itself.

Thank you for your time.

Andrew.

#2669359

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screenshot 2023-11-29 at 16.22.11.png

Hi there

All posts, whether they are WordPress Posts or custom posts, are normally listed by date, but at the top of the page you can click the column heading to order by Title (or something else if there are other columns displayed).

I suspect you clicked to order by Title, and can revert to ordering by date by clicking the Date column header.

#2669591

Hi.

I said in my question that I know they can be re-ordered by clicking the heading title.

That is not my question.

The custom post types created with Toolset are by default ordered alphabetically. Not by date. So every time an admin on the site loads the page they have to re-order by clicking the date title.

Then next load, they are ordered alphabetically again.

This should not be.

They should be ordered by date by default – as you yourself say.

I need help in fixing that please.

Best wishes,
Andrew.

#2669607

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

What Nigel shared is correct. I'm not sure why you are getting title as default sort order.

Here is a sandbox site and you can auto-login to it using the following link:
- hidden link

If you check any custom post types created using Toolset, you will notice that the post type is set to order by Date by default. For instance:
- hidden link

If you see the header for column Date - the session listing is set to order by Date. Are you using any sort order add-on plugin?

#2669609

Hi Minesh.

I know how it is meant to be. The point is that it was not behaving as it should.

I have been able to resolve the issue myself with some code in functions.php as follows:

function custom_posttype_admin_order($wp_query) {
if (is_admin() && $wp_query->get('post_type') == 'posttypeslug') {
$wp_query->set('orderby', 'date');
$wp_query->set('order', 'DESC');
}
}
add_filter('pre_get_posts', 'custom_posttype_admin_order');

Very best wishes,
Andrew.

#2669629

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok great - you're welcome to mark this ticket resolve.

#2669663

I can't mark resolved without spending tome doing pointless ratings of the support. I should not be FORCED to do this and will not.

#2669671

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

As shared details with my previous reply with the details of the sandbox site - I do not see the issue.

We are not forcing you to close the issue but I thought you found workaround and you want to keep that as I do not see the issue with the sandbox site.

Did you check the sandbox site? Have you able to see the issue with the sandbox site? If no - then there must be something that should be overriding the order or you should send me the exact steps that I should follow to see the issue on the sandbox site I shared.

#2669679

For goodness sake.

I told you the issue is resolved because I fixed it myself.

I even pasted the code here that fixed the issue in case anyone else in future has the same issue.

I am telling you I am unable to mark the ticket resolved because your system only allows me to do so by giving ratings.

I won't do that.

Mark it resolved if you want.

I won't be commenting again.

#2669681

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The issue is fixed with workaround.