• Resolved vahan889

    (@vahan889)


    Hi !

    I’m using WP_Query to get posts of the category and during my work I recognized that when the term has only one post then your filter don’t allow me to get the post cause of the condition which is adding with the add_filter('posts_where', array(&$this, 'reOrder_query_where'), 10, 2);
    filter (wp-content/plugins/reorder-post-within-categories/reorder-posts-within-categories.php:69).

    Also I can’t access to the category from the settings page (options-general.php?page=reorder-posts-within-categories.php) because it has only one post for now. In the reOrder_query_where function doesn’t exists any hook to use and fix it.

    Can you help me to fix or find a solution for it?

    Thanks in advance,
    Vahan

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    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

    Thread Starter vahan889

    (@vahan889)

    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

    Plugin Author Aurovrata Venet

    (@aurovrata)

    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.

    Thread Starter vahan889

    (@vahan889)

    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.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Post are missing of the category’ is closed to new replies.