Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

How to query post ids liked by the Author

Your query would be something like:

$post_ids = $wpdb->get_col( "SELECT DISTINCT post_id FROM {$wpdb->prefix}wti_like_post WHERE user_id = {$author->ID}" );

Then you can pass that array of post IDs as the post__in argument of WP_Query:

$args = array(
    'posts_per_page' => -1,
    'post__in' => $post_ids
);

Related Posts:

  1. Query Custom Meta Value with Increment
  2. I need query_posts() to order results first by a meta value and then by post ID
  3. When should you use WP_Query vs query_posts() vs get_posts()?
  4. order by numeric value for meta value
  5. Wp get all the sub pages of the parent using wp query
  6. How to query for most viewed posts and show top 5
  7. WP_Query vs get_posts
  8. What is the most efficient way of querying posts based on visits and date for current day?
  9. Get posts by meta data OR title
  10. Perform query with meta_value date
  11. WP_Query ordered by custom field that is a date string?
  12. Pass the same object to multiple widgets in a template with one query
  13. Retrieve or Query Pages by ID
  14. How do you query wordpress posts using a math formula between multiple meta field values?
  15. How to implement time filter to show random post 1 month for one category and 3 months for other categories
  16. Page navigation doesn’t show when query category
  17. Query post with meta_query where date is not in future
  18. Pull post meta with post_query?
  19. How to query a custom post type with a taxonomy filter but display post type archive page?
  20. Change query_posts to WP_Query in page but does not work
  21. Custom Query num_rows returns wrong amount
  22. Fetch Record based on meta key dates
  23. Slow page loads due to WordPress Core Query
  24. how to make members list directory through wordpress post custom meta key.
  25. How to increase load time of an archive/search page (WP_Query)
  26. Query Page Content From Theme Options?
  27. How can I override one post and make it display content for another post?
  28. Include current post into loop
  29. WordPress query posts with multiple post_meta data
  30. Filter post query to only show direct children of category
  31. Should I reset $wp_query?
  32. Why doesn’t my WP Meta Query return any results?
  33. WP_Query meta compare must include ALL array values
  34. Filter products on category AND tag
  35. How do i create a custom post query when the meta value is an array?
  36. pre_user_query vs pre_get_posts
  37. Get posts that match defined arrays of tags
  38. Query against multiple locations within single custom post type post
  39. How to show post title in content editor in backend?
  40. My entry results are not consistently alphabetized
  41. Merge two queries and remove duplicate
  42. WP_Query with child element
  43. Ordering Posts by parent category, name ascending
  44. Optimising specific Query with ACF meta objects
  45. How to get several fields from wp_query?
  46. How to organize a WP_Query’s list of posts by category and display category title?
  47. When should you use WP_Query vs query_posts() vs get_posts()?
  48. WordPress Query showing multiple titles
  49. Query Posts by date range with fixed beginning and end
  50. custom query to get posts
  51. query by meta value then date and not empty meta value
  52. Query posts by meta value and sort by another meta key
  53. How to get posts that have certain meta key value and order based on another meta key’s value
  54. Modify WordPress Search
  55. Nested array issue in meta_query
  56. Write WP Query that selects posts that are part of the same two categories
  57. Display post meta conditionally based on it’s value
  58. Creating attachments archive in tags and categories
  59. How to use ‘WP_Query’ or ‘query_posts’ to display content in a descending order
  60. Get next/prev image/attachment in time with date query
  61. Filtering by multiple conditions in the loop
  62. WP_User_Query orderby meta_val_num
  63. WP_Query custom order and pagination
  64. 2 queries with counters
  65. Show single posts date, in a page of posts
  66. Sort by custom field that is an array?
  67. Orderby two meta fields not working
  68. Max Posts and Memory Limit
  69. How to SQL query posts IDs by categories AND authors?
  70. Display count number of posts with the same specific meta_key meta_value
  71. specific post is not excluded from the loop
  72. Unable to paginate a custom page query
  73. Include one page/post into query which is already returning posts
  74. I am officially missing something about transient posts
  75. Insert images into wordpress post with a query
  76. Multiple Query_Posts
  77. Query posts by searching for a string in a meta field
  78. Paginate pages with dynamic query
  79. filter posts by meta key with pagination
  80. Trouble Making WP_Query paged
  81. Performance concerns: index.php vs taxonomy-$taxonomy.php
  82. Determine if ID is page or post and query the ID
  83. How to query for a page, get data, then query for child pages of that page
  84. Custom template for password protected page
  85. WP_Query Class custom field parameters
  86. Start Query from 2nd Post without offset
  87. Add AJAX “Load more” on custom query block
  88. Disable (or limit) queries when certain content (or data) is not needed (or showed)
  89. Posts limit on homepage (genesis framework)
  90. Magazine style frontpage with multiple categories/loops and no duplicate posts
  91. Display upcoming events in the next 30 days by querying posts with timestamp in custom meta
  92. Prioritising and Ordering Posts By Category Name Using A Custom Loop
  93. Optimising WP_Query with ACF Fields
  94. meta_query where the meta value is not the post title
  95. Elementor posts custom query based on tag [closed]
  96. Query post and sort by custom value calculated with custom field on cpt
  97. Post incorrectly excluded when using “category__in”?
  98. Query multiple post types, but different order for each
  99. Multi-layered WP_Query
  100. `offset` WP_Query argument dont work via `pre_get_posts`
Categories wp-query Tags post-meta, query, query-posts, wp-query
WordPress sites translate dynamically generated Homepages
Get result from Custom Field in Custom Post type

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress