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()?
- Default table collation on plugin activation?
- How to add multiple custom URL variables?
- Why Does get_posts() Return an Empty Set?
- Get posts by menu ID
- Slow SQL_CALC_FOUND_ROWS Query
- What is the added “complexity” of custom tables?
- How to modify post content before writing to database?
- Actions or filters fired when data is saved in a custom table
- How to get all images and their thumbnails from wp media library
- Display only certain posts based on visitor’s country?
- How to create a dynamic page based on form data with a plugin?
- How to Display Custom Post Type’s Gallery (images ) in Through WP_Query
- How to find if a post with custom_field == X exists?
- Handling form request from plugin file
- Passing array of strings to a SQL statement in a WordPress plugin
- How to get orders with used coupon in WooCommerce
- What for the tables ending with the meta used in database of wordpress?
- query users by role
- WP_Query returns no results
- Finding posts containing matching array elements in a meta field usign WP_Query
- Create a custom display order in the main menu
- Order by custom table and multiplication
- How to Create database table when Plugin installed/activated, and delete database when Plugin deleted
- I’m designing a plugin to create database indexes. Suggestions?
- Create WP_Query to search for posts by their categories or their parent/child categories
- Are there any scripts, classes, and/or functions built-in to WP for a plugin to export/import its saved data from wp_options?
- Strange issue saving custom field data for a WooCommerce order
- Form doesnt save to database
- Updating Woocommerce Settings API when WordPress Settings API saved and vise versa
- How to fetch only current hour posts?
- Update results, Before deleting the related category [closed]
- Is using custom table to suit business needs instead of transients a big hit to page load speed?
- How to add user details to different tables immediately after user registration
- inserting a post from an extern php file but post content doesn’t show on wp site
- mysql_real_escape_string() vs. esc_sql() in WordPress
- how to get all the child category name in a specified category name?
- Optimising a big WordPress site
- How I can use order by of the custom post title?
- What is the best way to store a few fields?
- Delete data from database using row action
- How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?
- Prevent WordPress automatically processing certain URL queries
- wpdb prepare insert table doesn’t work
- Make Database query only when option is updated
- Store custom meta box data as serialized array
- How remove trashed WooCommerce orders from wc_get_orders() result?
- WP_Query with page_ids in arguments without a result
- WordPress plugin: efficient way to store large data
- Get post thumbnail in WP_Query
- Brainstorm – Slow Query from Plugin Need to Speed It Up
- How do I debug an error that a plugin is causing?
- Create an user on external database
- Update plugin settings option_name for big plugin update
- What could cause a WP Option to get truncated?
- select a single val though a table in wordpress
- Integrating Custom Database with WordPress
- How to display results from a data table with an encrypted user id?
- Error code when migrate
- Multiple dynamic Tax Query – pass taxonomy argument from array
- Why last row deleted when refresh page
- How to get inserted row IDs for bulk/batch insert with wpdb query?
- Group By in a Metaquery
- Use admin-post to submit form data to external database
- Save in my custom admin page and redirect to the saved object
- WordPress delete mysql rows with string
- How to store in the database directly the translation?
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- sql query not working in wp plugin
- $wpdb Mysql trigger problem
- Associating special meaning with user id 0
- 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
- How to add additional field in a table row after creating a table?
- WordPress plugin tables become corrupt
- Nothing happens on WordPress Update command
- How can I delete the options from DB when the plugin is deleted?
- How to create a database table in WordPress using PHP
- SQL query into to WP query
- Return custom product in ajax call loop
- Making a user platform reachable by a qr code on a pin-back-button [closed]
- multiple record insert creating many duplicate records