Check WordPress Content Exists or Not Before Post

Posted By TimesCoding Staff | June 19, 2022 | 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");
}
?>



Author: TimesCoding Staff

TimesCoding Staff is a member of the team, and an expert in HTML, CSS, JavaScript, PHP, Ajax, and WordPress theme development.

Read Next