when the term has only one post
if you only have 1 post in your term then there is no ranking possible, right? So its stand to reason that the plugin doesn’t allow you to order. You need to have more than 1 post in order to rank them
hi @aurovrata ,
Yes, you are right, when only one post exists in the term then there is no ranking possible.
But in the filter where you adding the condition in the query’s “WHERE” section, the post can’t be retrieved with WP_Query because there is no saved information about the post and category in the wp_reorder_post_rel table. I hope you understand the problem I described.
Thanks,
Vahan
Can you send me the final SQL query of your WP_Query?
The plugin should not interact with your post query if that term is not ranked manually.
here is the args of WP_Query:
Array
(
[post_type] => my-post-type
[meta_key] => visibility
[meta_value] => visible
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => my-category
[field] => id
[terms] => 31
)
)
[paged] => 1
[posts_per_page] => 25
[orderby] => menu_order
[order] => ASC
)
here is the request:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts
LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )
INNER JOIN wp_reorder_post_rel ON wp_posts.ID = wp_reorder_post_rel.post_id and incl = 1
WHERE 1=1 AND (
wp_term_relationships.term_taxonomy_id IN (31)
) AND (
( wp_postmeta.meta_key = 'visibility' AND wp_postmeta.meta_value = 'visible' )
) AND wp_posts.post_type = 'my-post-type' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled')
AND wp_reorder_post_rel.category_id = '31'
GROUP BY wp_posts.ID
ORDER BY wp_reorder_post_rel.id ASC
LIMIT 0, 25
You can see here that added wp_reorder_post_rel.category_id = ’31’ this line and this term has only one post but in the wp_reorder_post_rel table there is no any information about the term.
wp_reorder_post_rel.category_id
is not from this plugin. Likely you have another reorder plugin installed that is impacting your query.
This plugin file ReOrder-posts-within-categories/public/class-reorder-post-within-categories-public.php
(line: 90) appends the following ranking SQL string to the WHERE clause AND rankpm.meta_value={$term_id} AND rankpm.meta_key='_rpwc2'
when the query finds a term that is being manually ordered.