• Resolved Eli Antebi

    (@eliantebi)


    I need to display the order index in the website UI.
    How can I get this parameter within the loop?

    Also, I want to query all posts by taxonomy AND by boolean custom field. Once I do that – the ReOrder breaks – it doen’t show the real ReOrder. Can I make ReOrder work with both tax_query and meta_query on same query?

    And last one – what is the meaning of “Use the manual sorting for this category”?

    • This topic was modified 8 years, 12 months ago by Eli Antebi.
    • This topic was modified 8 years, 12 months ago by Eli Antebi.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    Hi Eli

    I need to display the order index in the website UI.
    How can I get this parameter within the loop?

    beyond a simple counter that you increment after each loop, if you wish to get the index value stored in the custom table you will need to actually pull them out with a custom query targetting the table,
    `$table_name = $wpdb->prefix .”reorder_post_rel”;

    the column ‘post_id’ stores the id of the post
    the column ‘category_id’ stores the term id
    the column ‘id’ stores the sorting index.

    Also, I want to query all posts by taxonomy AND by boolean custom field. Once I do that – the ReOrder breaks – it doen’t show the real ReOrder. Can I make ReOrder work with both tax_query and meta_query on same query?

    sure, but you can’t do it using the ‘pre_get_posts’ filter. This plugin uses the ‘posts_where’, ‘posts_join’ and ‘posts_orderby’ to build the required query.
    Hence, you should be able to get your meta field condition to work by hooking the ‘posts_where’ filter.

    And last one – what is the meaning of “Use the manual sorting for this category”?

    manually re-order by drag & drop and for which the plugin will manage the displayed order.

    Thread Starter Eli Antebi

    (@eliantebi)

    Thank you very much for your help; I have no idea how I missed that table, was looking for it all over the DB to understand how you’re storing the data.

    Unfortunatly this doesn’t solve my big problem, which is to get the sort-index, the one that I gets by a simple increment in the archive page as you mentioned – inside the Single page.

    My challange is to create a continuous ID for each post in each category. Your plugin is great and allow my to manually sort posts by category, but unfortunatly since you’re using uniqe id for the entire table and not a “soft-index” column that is uniqe/continuous for each category – that doesnt help me to get the real sort-index of the post…

    Plugin Author Aurovrata Venet

    (@aurovrata)

    Hi Eli

    My challange is to create a continuous ID for each post in each category.

    how would order the categories themselves? If you use their term_id (the natural order), then you could easily create a natural index by combining both post and term index as string $term_id.$id and then casting the string to an integer. This would give you numbers like 01, 02, 03, 11,12,21,22,23,24.

    It would then be easy to pass these an array and re-index them 1,2,3,4,5,6,… and so on.

    However, if you need to re-order category terms themselves, there are plugins to do so, and I guess you then use their custom index to do the same.

    Anyhow, that’s an interesting problem, and one I will keep in mind when I re-write this plugin.

    Thread Starter Eli Antebi

    (@eliantebi)

    The basic and “stupid” solution is just to make a loop on the posts table at the top of the single page, and run the increment like the archive, and once I got to the same post ID – stop the loop and capture the counter. heavy but works.

    The big picture is a bit complicated:

    I have Players CTP
    Each Player related to one Team taxonmy

    The Team archive page shows a list of playes in a given team (taxonomy), which the UI-design required to show its fake-ID, lets say “01/200”, “02/200″…. “200/200”. The 200 refers to the amount of players in this specific team (taxonomy).

    I also have client-side filters on that archive page, like “show only male”. That filters the list to let say 150 players, who should keep their fake-ID visible. Not big deal since it’s on the client side and I just show and hide irrelevant players.

    Now here’s the problem: On the single page, where I should show this player fake-ID, I should also show next/prev player link which should take into consideration the male/female filter 🙂

    I cant guess what is the next mache post and what would be it’s sort-index on that filtered taxonomy…That’s why I must have a DB key for the ordering, one that I query the database based on it… So I find the current one, and simply quesry the following.

    Thanks anyway!!

    Plugin Author Aurovrata Venet

    (@aurovrata)

    Now here’s the problem: On the single page, where I should show this player fake-ID, I should also show next/prev player link …

    if you store the team (term id), and the order index, you can easily search the table order for that term id, and return the post_id (player) for the next incremental id. That shouldn’t be too difficult with a custom $wpdb query.

    …which should take into consideration the male/female filter

    now that’s where it becomes more tricky. If you implement the next/prev link using an ajax call, then you can pass the filter status. You then need to keep scanning the order table until you get a post_id of a player that matches your filter. I can imagine the most efficient way to do this would be to create a stored procedure on the database itself, so you look at the next player in the ordered team list, then check if the player matches the filter and keep looping until you either get a match or run out of players. Your stored proc could even return bott the prev and next player this way.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Get ReOrder position index in UI’ is closed to new replies.