• Okay, I’ve got a long one…Here’s what we’re trying to do: We’re running Buddypress with a few custom post types (Book, URL) which users can add through a form on the front end. When a new Book is added, the Title, Author, Unique ID of Book, User ID of the person who added it, and a few other fields are added as metadata and custom taxonomies. If a new user attempts to add a book which someone else has already added, it doesn’t create a new post, but instead just adds their User ID to the list of Readers (which is a custom taxonomy).

    Each user has their own individual “Shelf” of items that they’ve added, however to display this we are simply creating a custom WP Query instance which looks for any posts with a specific User ID in the Readers taxonomy. All this happens perfectly, but the issue has to do with the order of the books on each individual user’s shelf. Right now, it is sorted by default (publish date) so if you add a new book, it shows up most recently in your queue. But if you “add” a book that has already been added by someone else (so you’ve really just updated a pre-existing Post), this book will appear in the queue in relation to its ORIGINAL publish date, not the date that you’ve added it.

    Okay, thanks for sticking with me, here is where we need some help: We’d like to add some kind of metadata to each post to keep track of the position in a specific user’s queue. One way I was considering to do this would be to create a new table and relate the User ID with the Post ID (the book) and then add a Sequence number which would represent where in the person’s queue the book should show up. However, my knowledge of SQL is very lacking and not sure how to tie in with WP’s pre-existing query methodology. Anyone think they can point me in the right direction?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Custom SQL Query for Relating data’ is closed to new replies.