The following should do the trick:
global $wpdb ;
// get the post_ids from the custom table
$sql = "SELECT listing_id FROM {$wpdb->prefix}wpdbdp_listing_fees WHERE fee_id = %d" ;
$sql = $wpdb->prepare ($sql, 4) ;
$post_ids = $wpdb->get_col ($sql) ;
// get the custom posts from the posts table
$args = array (
'post__in' => $post_ids,
'post_type' => 'wpbdp_listing',
) ;
$posts = new WP_Query ($args) ;
foreach ($posts->posts as $the_post)
echo $the_post->post_title ;
}
Note the use of $wpdb->prefix
in the SQL statement.
Related Posts:
- Getting wrong relationship value in $args in wp_Query?
- How to get data from WordPress $wpdb into React Gutenberg Blocks Frontend?
- How is the data stored in the database?
- Activation hook not creating table
- Is the usage of ON DELETE CASCADE wrong or not allowed on wordpress?
- Version upgrade: can my plugin filter the SQL statements issued during a database upgrade?
- WordPress database error for query INSERT INTO
- How to connect to AWS RDS external database (not for the core WordPress db)
- How to create database table, add data, update and delete using wpdb via plugins?
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- Using AND and bracket grouping in SQL not working
- Two different wordpress sites – same server and IP address. Gaining Access to database 1 of 2
- Auto-complete or auto-suggest from stored data in database
- What might be the reason of Couldn’t fetch mysqli_result on another domain?
- WordPress database error: [Query was empty] – using $wpdb->prepare()
- WordPress how do I echo SUM from a column of a MySQL table by user id AND type_operation
- WordPress doesn’t create table on plugin activation
- Custom MySQL query to pull out Advanced Custom Fields?
- How to filter get_adjacent_post()?
- Should I use wpdb prepare?
- Post meta vs separate database tables
- Is it mandatory to use $wpdb->prefix in custom tables
- Update Option Stored in Multi-Dimensional Array
- WP_Query leaking absurd amounts of memory
- Fatal error: Class ‘ms\WP_Query’ not found on plugin initialization [closed]
- Default table collation on plugin activation?
- Creating two database tables via plugin
- Using a database view = evil incarnate?
- Error code when migrate
- What database state changes happen after a post is manually “updated” with no changes?
- Multiple dynamic Tax Query – pass taxonomy argument from array
- Why last row deleted when refresh page
- Why User_login key doesn’t work with wp_update_user()
- WP_Query not ordering correctly
- How to check category name available or not
- Home page is not loading, where in other pages are displaying on the site
- Insert, update or remove data from database (usermeta)
- How to get inserted row IDs for bulk/batch insert with wpdb query?
- how to create a shortcode from a variable in plugin
- Why is that only the first row getting inserted into Mysql table when i import csv file on backend custom plugin?
- Error Connecting to Database WHEN Installing WordPress on XAMPP [Tried All the Usual Stuff] (Pics Included)
- WordPress Fatal error: Uncaught Error: Call to undefined function dbDelta()
- User meta query using Wildcard
- Fix wp_term_relationships slow query in get_posts
- Group By in a Metaquery
- Is it possible to replace MySQL with JSON files for WordPress
- WP Query date_query with several date range
- Use admin-post to submit form data to external database
- Save in my custom admin page and redirect to the saved object
- Relational / Associate tables using native WordPress functionality
- Insert Data into Database
- Update database record in plugin
- WordPress delete mysql rows with string
- How to store in the database directly the translation?
- Organising and completing posts (mark as read and hide)
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- Making Woocommerce optimized for more than 500k products
- Post Pagination does not working on WP-Query
- WP Query Relations / Compare
- Plugin MySQL SELECT custom data and filter on user meta
- How can I query 3 posts from diferente categories (one of each category)
- sql query not working in wp plugin
- $wpdb Mysql trigger problem
- Query only title/field/featured media of posts [closed]
- Ajax not working to insert, query and result data
- Why Worpdress doesn’t create table in database?
- Form and database, plugin development
- Associating special meaning with user id 0
- WP_Query always returning the last custom post
- $wpdb how can i save my postmeta table before querying it
- post_results filter confused by pagination in sidebar and main section
- What method should I use to store my plugin data (multi level menus with options on each item)
- Can’t get query string in ajax call
- Get custom wp_query search results to appear on search.php
- How to add additional field in a table row after creating a table?
- WordPress plugin tables become corrupt
- Post data in wp-admin to external database
- loop and in admin header problem
- Nothing happens on WordPress Update command
- How do I query posts and have their related taxonomies returned in the results?
- Custom query_posts() parameter
- How to edit the default database of WordPress [closed]
- Best Way to Inventory the Media Library of a 200+ Multisite Installation?
- How can I get a plugin to hook ‘dbdelta_queries’ — a filter used during version update?
- Running one-off cron jobs when WP_DISABLE_CRON is true: can I hit /wp-cron.php?
- $_GET vs get_query_var()
- How can I delete the options from DB when the plugin is deleted?
- What is the meta_query key name for the woo product average rating? [closed]
- How to create a database table in WordPress using PHP
- SQL query into to WP query
- get the queried_object of an url
- Return custom product in ajax call loop
- Execute multiple PHP Snippets causes error?
- Leveraging Core Functionality in Icon Upload Plugin [closed]
- Can I log the searches that are returning 404 in the DB?
- Programmatically creating posts based on external JSON feed (asynchronously)
- filter on get_posts efficiently
- WordPress database error: [Table ‘bitnami_wordpress.questions’ doesn’t exist]
- Making a user platform reachable by a qr code on a pin-back-button [closed]
- multiple record insert creating many duplicate records