What sort of unique data are returned by your external SQL query? I would assume that you would need to insert some sort of unique data (e.g. primary key from the external DB) as either $post data or metadata, and then your conditional could look for the existence of these unique data.
Alternately, you could hash the postdata from the external DB, and then store the hash value as $post metadata, and query on the existence of the hash value?
EDIT:
To query for specific $post metadata, use the get_post_custom()
function (Codex ref). e.g.:
$mypostcustom = get_post_custom( $post->ID );
if ( ! isset( $mypostcustom['unique_query_data'] ) ) {
// Unique query data not found; do something
} else {
// Unique query data found; do something else
}
Note: this assumes that you’ve already worked out how to add the custom post meta, e.g. via add_post_meta()
(Codex ref).
Related Posts:
- delete post also attachments
- Allow role to delete posts but block him the wp-admin
- Why does `url_to_postid` return 0 when testing `page_for_posts` Page?
- Delete Post From Front-End and attachment permanently
- Run a function when post is deleted?
- disable Tab post on nav-menus page (Admin)
- Format latest/newest post differently
- How safe is it to delete old posts edits to save database space?
- Optimize CPT-function with a loop
- How Can I Always Display A Particular Post First Using WP_Query?
- How to put the author of the post in the comments?
- Alt text attributes not showing over portfolio images
- How to add a custom class attribute into code wrapper? [duplicate]
- Given two custom post types: Automatically add meta fields from one custom post type to another
- How to change the case of all post titles to “Title Case”
- How to display by default only published posts/pages in the admin area?
- Post/Page Preview Template
- using wp_update_post on save_post
- How to Group Posts by the First Letter or Number?
- WordPress plugin to publish to multiple remote WordPress blogs
- Any way to create a revision of a post ONLY with a new button in the Meta Box?
- How to display comments and comment form on custom post type?
- Code to auto expire posts after 30 days
- How to wrap every image in a post with a div?
- Show One Category on Post
- Custom colors for post rows based on post meta value
- WordPress Delete hook with wp_delete_post function?
- Custom post type single (permalink) throws a 404 error
- Order post by year DESC and month ASC
- Custom wp_trim_words() function not trimming right
- Do I use custom post type or something else?
- Limit function to specific post category
- Custom post type permalinks breaking due to 3.1 bug fix
- When paginating a Page with the tag, how can the 2nd and subsequent page styles be customised?
- Function to show random posts from a category
- ‘Invalid post type’ error when importing from one site to another
- Blogroll – Different layout for first post
- How to delete old posts’ edits to save space?
- How much of my site can I recover from public_html?
- Create cron job without a plugin?
- Uppercase first sentence in every post
- Extracting post categories
- How to make number of blog posts a custom field?
- WordPress blog or WordPress website
- Hiding Draft Post In Admin
- Force the “Choose from the most used tags” meta box section to always be expanded
- How to allow users to post only in certain category and hide elements from edit page?
- Making a custom Pagination for multi page blog post
- Copy post to separate database with “add_action(….)”
- When open add new post or page WordPress add post with ID=0 continuously [closed]
- Thumbnail & Category link aside post
- What do these phpMyAdmin errors mean on my WordPress databaes?
- why there are so many posts whoes post_type is revision? will these records waste too much database space?
- Delete all drafts?
- Is there a way to create a meta box that can be added multiple times to a post dynamically?
- WordPress custom post type with folder structure in slug
- How to add automatically bootstrap 4 order-lg-1 and order-lg-2 classes for columns in foreach loop based on the count?
- wp_posts table extremely large
- Defined function isn’t showed on page
- WordPress 302 Redirect to Random Product/Post/Page
- Show custom post with custom categories with specific slug
- How to call posts under a specific category on static front page?
- Add code to a specific post’s content
- Add post tags to previously created custom post type
- How to display only one category in a custom post type?
- Custom Post Type Single Loop Outputting Wrong Post
- Making a wordpress page print friendly
- WordPress Post Deletion Issue
- Your ideas on my though “delete or move all of the posts in a specific category when 3 days are passed”
- MySQL: Possible to replace all of wp_posts.post_content(id#) via UPDATE + REPLACE + SELECT?
- Change modified date to current date when title updated automatically
- Check if almost 10 year old – working code is up to date
- My website is showing today’s date instead of published date since db migration to a new wordpress
- Redirecting wordpress search query to archive page
- Bulk find & replace on WordPress posts/pages (minus image paths)
- How to create custom search form function including post “tags”
- Remove pagination if search returns empty
- Remove HTML tags from all posts
- Please I want to prefix my WP posts title according to each category
- How can I stop ‘in use’ message from intermittently blocking my wp_posts table?
- Save All Post Permalink From A Specific Category into a .txt file
- How to Display Most View Post in the template file?
- Customizing URL slugs of Custom Post Type and Taxonomy make posts/pages 404
- Show post excerpt
- How do I apply a wordpress function to something with no ID inside an archive page?
- Show author bio box
- Surrogate ID for posts, is there an alternative field in the posts table?
- How to retrieve custom field values and save again as array
- Expired Post with More Recent Time Stamp?
- Call image from post on index page?
- Is there a Standard Format for Clean URLs for Archives of Custom Posts?
- How do I get thumbnails?
- Run function after post is updated
- Checking if some condition is matched before inserting post into database
- Extra field in wp_post instead of postmeta
- Voting System, database connections?
- adding custom meta as well as looping through posts
- Notify Author of the post if admin deletes his post and perform some function
- How remove “recent comments” title without modifying code? [closed]
- Need to show birthday of custom post type(Famous people in this case) in elementor. Date of birth set in custom fields