Title: Get ReOrder position index in UI
Last modified: June 15, 2017

---

# Get ReOrder position index in UI

 *  Resolved [Eli Antebi](https://wordpress.org/support/users/eliantebi/)
 * (@eliantebi)
 * [8 years, 12 months ago](https://wordpress.org/support/topic/fetch-index/)
 * 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](https://wordpress.org/support/users/eliantebi/).
    -  This topic was modified 8 years, 12 months ago by [Eli Antebi](https://wordpress.org/support/users/eliantebi/).

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

 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/fetch-index/#post-9238418)
 * 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](https://codex.wordpress.org/Class_Reference/wpdb#SELECT_a_Column)
   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](https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where).
 * > 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](https://wordpress.org/support/users/eliantebi/)
 * (@eliantebi)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/fetch-index/#post-9239186)
 * 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](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/fetch-index/#post-9239227)
 * 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](https://wordpress.org/support/topic/multiple-post-types-in-same-custom-taxonomy/#post-8999696).
 *  Thread Starter [Eli Antebi](https://wordpress.org/support/users/eliantebi/)
 * (@eliantebi)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/fetch-index/#post-9239256)
 * 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](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/fetch-index/#post-9243495)
 * > 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](http://www.w3resource.com/mysql/mysql-procedure.php) 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.
    -  This reply was modified 8 years, 11 months ago by [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/).
    -  This reply was modified 8 years, 11 months ago by [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/).

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

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

 * ![](https://s.w.org/plugins/geopattern-icon/reorder-post-within-categories_c18d38.
   svg)
 * [ReOrder Posts within Categories](https://wordpress.org/plugins/reorder-post-within-categories/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/reorder-post-within-categories/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/reorder-post-within-categories/)
 * [Active Topics](https://wordpress.org/support/plugin/reorder-post-within-categories/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/reorder-post-within-categories/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/reorder-post-within-categories/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * Last activity: [8 years, 11 months ago](https://wordpress.org/support/topic/fetch-index/#post-9243495)
 * Status: resolved