0

How can I Fetch posts that are stored in the different table than the default table (wp_posts)?

1 Answer 1

0

Try below code

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

Replace TABLE_NAME with your custom table name.

3
  • Where should I add this code? Commented Jan 24, 2017 at 13:19
  • the name of the table: blogb_posts Commented Jan 24, 2017 at 13:24
  • You can create a short code using this code and add the short code in your page template or in the edit page section. For short code please refer - speckyboy.com/… Commented Jan 24, 2017 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.