Skip Navigation

[Resolved] WP Archive default page ordering the list

This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 3 voices.

Last updated by Luo Yang 6 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#1097146
ch-list.jpg

Tell us what you are trying to do?
hidden link
I want to organize the default page of Character archive page by category.

#1097373

If that is a View, then edit the View in question so to use what you need in the "Ordering" Settings of the View.
(See Screenshot).
This can however only be by native Post Data or Custom Fields.
To order Posts by their Taxonomy Term, you would create a Taxonomy View ordered by Term name, then, in that View Loop, insert the Post View that displays Posts by Terms set in the parent View.

On post Archives, this is not possible, because the archive itself already displays posts and cannot take a parent rule anymore (View that returns Taxonomy terms).

This is not a limitation of Toolset but native WordPress does not support ordering by taxonomy itself.
(This means, you cannot even do it with Custom Code hooked to pre_get_posts() using core WordPress API)

The only possible approach hence is either extensive Custom PHP code or doing it with a nested View as above shown instead of an Archive.

I like the design of the example you show very much, BTW.

#1099767

that is post Archives page.

So if I am using PHP something like this example:
<?php
// global $post;
$args = array(
'post_type' => 'post',
'order' => 'DSC',
'posts_per_page' => 3);
$product_posts = get_posts( $args ); // returns an array of posts
?>

I know it is possible to manage the structure but I cannot embed this PHP because I am using toolset WP archive.
In this case, what should I do?

Thank you 🙂

#1100213

Hello,

For the new question:
I cannot embed this PHP because I am using toolset WP archive.

I assume you are going to setup some custom parameters in the archive page query,
If it is, you can try WordPress built-in action hook "pre_get_posts":
https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts

#1100240

Hello,
I would like to use "pre_get_posts" hook, but how to put custom PHP code to archive page if it was created via toolset archive editor (not via simple WordPress archive page)?

Thank you

#1100269

There are lots of example in the document I mentioned above:
https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts#Examples

Section "Examples"

You just need to put custom PHP codes into your theme file "functions.php"