• Resolved XXVII

    (@xxvii)


    Hello,
    your plugin doesn’t work correctly when the same taxonomy is shared between more than one post type.

    I give you an example.
    I have one taxonomy “Tipology” which is used to categorize two custom post types: “Products” and “Accessories”

    If I order the products of a given tipology term, the wp_postmeta table will contain the ordered ids of the products of that term, but if I try to query the accessories of that term I will have zero results, because the LEFT JOIN wp_postmeta AS rankpm ON wp_posts.ID = rankpm.post_id
    is trying to match the accessories ids in wp_posts with the products ids in wp_postmeta.

    To solve the problem you need to store also the post_type in wp_postmeta.meta_value like “term_id-post_type”.
    For example, if you have to store the ordering of an “accessory” custom post type inside a term with id 10, the wp_postmeta.meta_value should be “10-accessory”.

    In this way you can have a custom ordering for every custom post type used in shared taxonomy.

    What do you think?

    In the meantime I would need a way to bypass your plugin, I tried with 'suppress_filters' => true but your plugin is still changing the query.

    Thank you!

    • This topic was modified 5 years ago by XXVII.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    plugin doesn’t work correctly when the same taxonomy is shared between more than one post type.

    that’s good to know. The plugin was never conceived for this scenario, although this is something on my bucket list to achieve and while re-writing it (v2) I kept this requirement in the back of my mind and have yet to make it fully compatible for multi-posttype taxonomies.

    LEFT JOIN wp_postmeta AS rankpm ON wp_posts.ID = rankpm.post_id
    is trying to match the accessories ids in wp_posts with the products ids in wp_postmeta.

    correct

    To solve the problem you need to store also the post_type in wp_postmeta.meta_value like “term_id-post_type”.

    this is not required, as teh default query is already specifying the post type.

    This is the current sql join/where query,

    LEFT JOIN wp_postmeta AS rankpm ON wp_posts.ID = rankpm.post_id AND rankpm.meta_value={$term_id} AND rankpm.meta_key='_rpwc2'

    and it is linked to the wp_posts table on the post ID which is sufficient to specify the post type.

    The issue lies in the handling of the ranking configurations and settings.

    Obviously I have done a good enough job, and neither did I test it.

    Let me take a closer look and I will release v2.3.0 shortly with a fix.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    I just released v2.3 with a fix for this. Please test it and let me know if it works for you too.

    dukan90

    (@dukan90)

    Hello,

    firstly thank you for this plugin. It is helping us a lot.

    But I have an issue with the version 2.3 where sorting within a category with multiple post-types should work, right?

    So, I have a custom post-type which is using the default “category” term along with the default “post” post-type.

    Somehow in the sorting screen (under “Reorder” of a post-type) only posts of that specific post-type appear in the grid.

    Do I have to activate a specific option to activate the sorting for multi-post-types?

    Thanks!

    • This reply was modified 5 years ago by dukan90.
    Plugin Author Aurovrata Venet

    (@aurovrata)

    @dukan90 please start a new thread as your question is unrelated to this one.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Bug when the same taxonomy is shared between different post types’ is closed to new replies.