You can use the WP_Query(); to check that like this:
$my_query = new WP_Query();
$my_query->query(array( 'meta_key' => 'X', 'meta_value' => 'Y'));
if ( $my_query->have_posts() ){
//it exists
} else {
//it's not here
}
Hope this helps.
Related Posts:
- Prevent WordPress from loading comments
- Retrieve and display data from custom db table in admin area?
- Custom search page and search by title, content and tag
- Create WP_Query to search for posts by their categories or their parent/child categories
- Fastest way to get the comment and ping total count for a post
- $wpdb->replace: WHERE?
- Custom SELECT Query With Multiple Meta Values (Ordering Problem)
- Applying WP-cli Search & Replace to Static SQL Dump File
- How Can I Always Display A Particular Post First Using WP_Query?
- What is my error trying to create a new table in the database?
- WP_Query always returning the last custom post
- Load more posts with multiple queries
- Hi, I wanted to make custom search with multiple fields
- Slow queries constantly getting stuck on WordPress database of ~100,000 posts
- Order by summing multiple values
- How to implement a new row_count method in WordPress?
- wp_query get post custom taxonomy in search.php
- inserting a post from an extern php file but post content doesn’t show on wp site
- Include data from custom table in WP_Query
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- No results found from a $wpdb->get_results() query when trying to join more than one meta key query
- wpdb custom tables without plugin
- WP_Query orderby and tax_query
- Order posts with a custom field but also without
- How to use default WP form elements to interact with custom DB table?
- Save title as custom field on custom post type
- My custom sql query for getting a username giving me a warning and an error
- Query multiple tables at once?
- Your thoughts on the interaction with one custom database table from WP?
- Add content in between of foreach
- Is it possible to query from external database? [duplicate]
- Custom Loop Query For Search Page
- creating new field on mysql
- Inner join overrides Advanced Custom Fields plugin’s get_field [closed]
- dbDelta not creating tables with composite keys
- Custom WordPress Table wpdb
- Best practice to limit results in get_row()?
- How to set up hierarchical relationships without using plugins / meta query
- how to get Nearby zipcode
- Always get creating a new table with foreign key
- Update query for wp_posts and wp_postmeta
- SQL query to set posts in bulk based on the post content
- Query Column of Specific ID from Database Table
- Setup database structure with books, authors, languages etc. for publishing house [closed]
- Query for specific custom field
- Get specific ACF key and value from all posts – no access to DB
- mysql query order by
- Add table to WordPress database
- Display posts by combining multiple meta key
- WP_Query with page_ids in arguments without a result
- Custom select query two tables by a meta key
- How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category
- Custom Same Page Search
- Fatal error Call to a member function insert() on a non-object [closed]
- custom user meta query
- Integrating Custom Database with WordPress
- Recent activity query WordPress
- How to query term_id of a Custom Taxonomy by name
- Custom Database Table and foreach
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- Is there a (preferable built-in) way to check what custom queries are used in a theme?
- SQL error with custom query
- query_posts meta_key with current date
- saving the widgets position after drag and drop
- WP Search Form Query: Add Author’s posts into search query
- query variables for custom taxonomies
- optimal taxonomy or custom post types
- export and import wordpress customization
- What database state changes happen after a post is manually “updated” with no changes?
- display text generated via custom get query string
- Get All Results From Other Users That Share The Same Custom User Meta As Current User
- Why last row deleted when refresh page
- Woocommerce Get Orders By Meta Value
- Migrating my site to a new domain does not keep any changes made in customizer
- WordPress how do I echo SUM from a column of a MySQL table by user id AND type_operation
- New Page/Post Screen Opens an Existing Post
- How select query is generated in a Custom Post Type?
- How to get meta key list efficiently?
- How to extend WP_query to a specific table?
- Fix wp_term_relationships slow query in get_posts
- Advice on how to structure a custom plugin
- Custom query pagination with php parameter as arg problem
- How to have differents sites share the same tables of DB?
- WordPress Database Query works in phpMyAdmin but not in the code
- Add to search posts query array with post IDS which will appear first
- How to automatically pull an information from a form field onto an other page?
- Query Posts to display all posts with category “custom field value”
- WPCLI search and replace in a particlar site dir effect another site-dir
- Query doesn’t display text data with apostrophes
- Custom Form Input not saving to Database
- Merging development site with live site
- pull data from wordpress database
- How can I display a query in a page?
- Accountless password generation
- Add commentmeta custom field to every published comment with SQL
- Query 1 custom post type, each day, alphabetically
- wpdb get_results() returns only 2 rows
- wp query custom orderby not custom field
- Get multisite count without php?
- Add several fields from different tables to post, fields per post are in same row of table