TimesCoding

Learn, Practice, and Excel with our Coding Tutorials!

Check WordPress Content Exists or Not Before Post

June 19, 2022 1 Min read WORDPRESS

Are you want to post from front-end of the WordPress website?

You can check whether your content already exists in the database or not using the below code. It will prevent your website from duplicating content.

<?php
$content = $_REQUEST['frm_content'];

if ( ! function_exists( 'post_exists' ) ) {
  require_once( ABSPATH . 'wp-admin/includes/post.php' );
}        

$found_post_content = post_exists( '',$content,'','', '');

if ($found_post_content){
  echo "Content Exists");
 }
else {
    echo "Content Not Exists");
}
?>
Related Post:
Optimizing WordPress Search Query Strings for Improved SEO-Friendly URLs − Search query strings are the parameters added to a URL when performing a search on a website. In WordPress, the default search URLs typically include.
Add Line Breaks to Woocommerce Product SKU & Category Name − We can easily add line breaks between product SKU and category name on the single product page. This formatting will make your product’s single page.