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 fetch posts that are stored in the different table than the default table (wp_posts)?

Try below code

global $wpdb;
$result = $wpdb->get_results($wpdb->prepare("SELECT * FROM TABLE_NAME));

Replace TABLE_NAME with your custom table name.

Related Posts:

  1. How to check if post meta key exists or not in wordpress database
  2. What is the use of to_ping and pinged column?
  3. How to add category to: ‘wp-admin/post-new.php’?
  4. Removing filter dropdown in posts table (in this case Yoast SEO)
  5. How can I retrieve multiple get_post_meta values efficiently?
  6. Code to make a post sticky
  7. How to allow hidden custom fields to be added from wp-admin/post.php?
  8. Export WordPress Posts and Meta Information in CSV format
  9. Delete duplicated wp_postmeta record
  10. How do you display posts in a dynamic table?
  11. Will a large postmeta table slow a site down?
  12. Update all posts automatically when using post_meta
  13. How to batch update post content with custom post meta value
  14. Change slug with custom field
  15. Better post meta efficiency?
  16. Setting post meta data to random value during post status transition / on publish
  17. Edit meta data does’t work with custom sql
  18. Human Time Diff, change mins to minutes
  19. Change post format using custom field
  20. Does WP get all post_meta on POST page?
  21. Sanitizing `wp_editor();` Values for Database, Edit, and Display
  22. Exporting Data from WordPress into a flat table
  23. Adding Multiple Values to a Post Meta Key
  24. Using radio button meta data from a custom meta box
  25. Custom fields on a virtual page
  26. PHP Notice error (when on 404 page)
  27. What Is meta_id In wp_postmeta?
  28. Checking if a post with certain meta value exists
  29. How to permanently delete a post meta entry?
  30. Add custom field automatically (add_post_meta) with value based on number of words of article
  31. How to generate numbers indistinguishable for the IDs of the posts
  32. Modify WP_Post before processing
  33. Save re-arranged draggable post items to wordpress database
  34. I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?
  35. Change post_date to post_modified date on post template?
  36. Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
  37. How can I sort posts by the date and a custom meta field?
  38. is there a way to show the the post title after the image?
  39. Get Meta Key Value While Saving Post
  40. problems with loading posts in a table-row
  41. Force the “Choose from the most used tags” meta box section to always be expanded
  42. Meta value does not save for scheduled posts
  43. Custom Posts Query and meta_query Sort Order
  44. How to compare two posts including their meta fields on a scalable base?
  45. Getting value from get_post_custom
  46. Calling Different Custom Post Timestamps in a table
  47. Is it possible to paste a link without tags and make it directly a link in a post?
  48. Cannot retrieve a custom RSS field from posts
  49. Saving custom fields to a custom taxonomy
  50. How to automate featured posts number? [duplicate]
  51. Why Query is returning empty array?
  52. Customize rel=canonical tag for single blog post
  53. Change all author links in Blog roll
  54. How to I retrieve the ID from the Posts page?
  55. How to save meta checkbox WordPress
  56. How to calculate the average of a post meta value(Numeric) of a specific author
  57. Is there any way to tell when wp_postmeta has been updated?
  58. wpColorPicker – problem with implementation to post meta
  59. Change post author without using wp_update_post()
  60. Private post caught in endless redirect loop
  61. How to retrieve all meta data directly from the $post object? Such as $post->related_topics?
  62. What is proper filter or hook action to add data to the $post object?
  63. Blogposting Schema & Structured Data without plugin
  64. Automatically select template based on query string for New Posts
  65. Display Updated Date Instead of Published Date
  66. How do you update post date (year only) in a separate custom field?
  67. Add postmeta to all blog posts
  68. Bulk Post update_post_meta
  69. Re-order Category Meta-data
  70. How to hide meta from search result only on pages?
  71. WP_Query sort by meta_value_num or date
  72. Grab meta data before post is saved
  73. Check if user has avatar
  74. alt of attached image in post / pages
  75. Creating Ordered Query using Meta_key
  76. Best Way to detect unique posts in wp rest api
  77. Get the correct meta_value with get_post_meta
  78. post_name is not stored until post is published… where should I store my slug until it goes live then?
  79. Filter question list on substring of metavalue
  80. Add a meta to a post submited from a frontend form
  81. Query post by meta key of another table
  82. Show posts between two Custom Fields date
  83. Add custom class to existing menu items from custom meta
  84. How to get only current images of a post
  85. Ordering posts alphabetically by meta keys and title
  86. Run function after post is updated
  87. Where should get_post_meta() go to get $post->ID get_post_meta() is empty and $post->ID & get_the_id() are working
  88. Adding custom fields to the Quick Edit screen – puzzled about the column concept
  89. Show related (archive) month and year to post
  90. How enter custom post meta or custom field on box post list archive page?
  91. WP_query sort by custom meta_key “price”
  92. If meta_key exists then don’t select this post?
  93. NewsPaper WP Theme – Additional Related Posts Filter by Time (divTag composer)
  94. What effect can a large wp_post table have on overall site performance?
  95. Site ‘Categories’: save an admin global setting with post metadata [closed]
  96. How to make internal links creating plugin to respect ACF?
  97. Translation related post text to Arabic
  98. WordPress post meta key and value lookup
  99. show the entire contents of posts in an archive page as a table
  100. How can I create Woodmart theme “linked variations” through REST API?
Categories posts Tags post-meta, posts, table
Why is one of my posts prefixed with “Next Post” on Google search
calculate values from a field and insert them into custom fields when publishing or updating post

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