Open bobbingwide opened 7 years ago
The current logic in oik_types_pre_get_posts_for_archive
attempts to determine the post_type for the query. This defaults to post
. So for taxonomy archives we can set the archive_posts_per_page for post
to be 102 ( divisible by both 2 and 3 ).
The orderby
still needs to be addressed.
For letter taxonomies, if it's not easy to provide an admin interface in oik-types, then this may be better achieved in the implementing plugin(s).
For the workaround to be effective it 1. Actually needs to be implemented 2. Should produce a reasonable result on the home/ blog page. A better solution would be to detect that it's an is_tax() or is_category() query and then use the max. value for any post type associated to the taxonomy.
One year on... the logic in oik_types_posts_orderby() is OK for taxonomies where we do want to display posts ordered by title, but produces unexpected results for blog posts. This was noted on WP-pompey.org.uk and has been raised as an issue in https://github.com/wppompey/wp-pompey/issues/4 for potential investigation in tomorrow's WordPress Portsmouth Meetup Clinic.
The "temporary" solution implemented in oik-types should be revisited.
Many month's later. I've found three more instances where the posts are being displayed in the wrong order.
The logic that tested for the value of the post type in the $query
object passed to the oik_types_posts_orderby
filter function assumed that if the post_type
was set in the query then it wasn't a query for posts. But when the query is for a selected taxonomy term the the value of post_type is set.
So we need to explicitely check that it's not post
before applying our override of the $orderby
.
And most recently I lwas wondering why the orderby for the question
CPT was by post_title ASC rather than the default. Again, it was the filter function oik_types_posts_orderby
if ( $query->is_post_type_archive() ) {
$orderby = "$wpdb->posts.post_title asc";
}
I'm wondering if the post_type should be tested to see if it's hierarchical ( like page ) before it changes the orderby.
So any post type which isn't hierarchical ( like post ) will continue to be sorted by post_date desc. oik_pluginversion?
I rather naively raised Gutenberg issue 30237 before investigating whether or not it was one of my own plugins that was causing the problem. I've now found another instance where changing the orderby produced the wrong results. This is explained in the issue at https://github.com/WordPress/gutenberg/issues/30237#issuecomment-806744632
The fix is to change oik-types and close the GB issue as Invalid/Wontfix.
My current requirement is:
archive_sort
defined for the post type if it's not blank eg post_modified desc
post_title asc
if the archive_sort
setting is set to title
.
Similar to the change in 44807de, where we provide archive sort and archive posts per page fields, we now require the ability to control what happens on taxonomy archives such as "letter" and "api_letters".
The whole point of having letter selection is to find the contents quickly, so we need to be able to display quite a few per page.