Title: Custom query for posts outside wp_posts table
Last modified: August 21, 2016

---

# Custom query for posts outside wp_posts table

 *  [JayKayBe](https://wordpress.org/support/users/jaykaybe/)
 * (@jaykaybe)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/custom-query-for-posts-outside-wp_posts-table/)
 * Hey,
 * I am currently building a website which will display user submitted image posts.
   I have a voting system which stores likes and dislikes in a custom mysql table
   in the format:
 * `ID` (Auto Incrementing)
    `PostID` (ID of the liked/disliked post) `Key` (`like`
   or `dislike`) `Value` (Number of Likes/Dislikes)
 * This is working perfectly fine. However what I want to do now is display two 
   different blog sections on the website. One in which all posts are initially 
   shown and one where posts are moved to that reach for example 20 likes.
    I have
   searched for a way to do this but haven’t found any query I could use to realize
   this. I know it would probably be better if the likes/dislikes would be saved
   as `post_meta` but the like system wasn’t implemented by me and I am not sophisticated
   enough to change this by myself. Unfortunately the support I’ve gotten from the
   guy who did it was very poor, still I kind of want to keep it and get this working
   somehow as the liking/disliking process itself is very good. If anybody could
   help me out with how to query for the right posts to display in each section 
   it would be awesome! Thank you guys for reading! Best Regards, Jay

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

 *  [FriendlyWP](https://wordpress.org/support/users/mmcginnis/)
 * (@mmcginnis)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/custom-query-for-posts-outside-wp_posts-table/#post-4590782)
 * If the system isn’t currently using normal WordPress custom fields / post_meta,
   we’d need to see what code it is using & how the data is stored before being 
   able to help.
 *  Thread Starter [JayKayBe](https://wordpress.org/support/users/jaykaybe/)
 * (@jaykaybe)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/custom-query-for-posts-outside-wp_posts-table/#post-4590814)
 * Hi Michelle,
    thank you for your response. I’m not quite sure what you mean by
   not using normal WordPress custom_fields / post_meta. The posts themselves are
   completely normal WordPress posts stored in the wp_posts table. It is just the
   likes which are stored in the custom table described below. The solution to my
   problem would probably be to do a query on the custom table to select every ID
   with 20+ likes and then query the wp_posts table to select just the posts with
   the IDs from the other query. However I am kind of scared to do so because I 
   am not very sophisticated with MySQL queries and both of them would query for
   about 30.000 posts. Can this impact server performance? Again if I misunderstood
   your question for more information please accept my apologies. Best, Jay
 *  [FriendlyWP](https://wordpress.org/support/users/mmcginnis/)
 * (@mmcginnis)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/custom-query-for-posts-outside-wp_posts-table/#post-4590829)
 * Hi again,
    You’d said in your original post:
 * > I know it would probably be better if the likes/dislikes would be saved as 
   > post_meta
 * That’s why I assumed your setup wasn’t using the normal WordPress custom fields/
   post meta to store the meta data (key/value) per post.
 * No matter what, I think you’ll need to post some of the current code and detailed
   information about how the data *is* currently stored in order to get some usable
   help. And given the advanced nature of the issue, this probably isn’t the right
   forum. You might want to try the WordPress [WP-Advanced forum](http://wordpress.org/support/forum/wp-advanced),
   or that and someplace like [http://wordpress.stackexchange.com](http://wordpress.stackexchange.com).
 * Best of luck!
    M
 *  Thread Starter [JayKayBe](https://wordpress.org/support/users/jaykaybe/)
 * (@jaykaybe)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/custom-query-for-posts-outside-wp_posts-table/#post-4590862)
 * Thank you for your answers Michelle! After looking into it I more and more realized
   this may be a little over the top for me to solve and after a brief search I 
   found another solution, where I have the likes/dislikes stored as post_meta and
   it works like a charm now!
    Best, Jay

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

The topic ‘Custom query for posts outside wp_posts table’ is closed to new replies.

## Tags

 * [likes](https://wordpress.org/support/topic-tag/likes/)
 * [query](https://wordpress.org/support/topic-tag/query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [JayKayBe](https://wordpress.org/support/users/jaykaybe/)
 * Last activity: [12 years, 3 months ago](https://wordpress.org/support/topic/custom-query-for-posts-outside-wp_posts-table/#post-4590862)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
