I have a function to insert a single post in the database.
But when I run the function, duplicate posts (40) are added to the database and then an error is displayed.
Fatal error: Maximum function nesting level of '100' reached, aborting! in C:\wamp\www\wordpress\wp-includes\cache.php on line 671
I would like it so that each time the function is run only one post is saved, without duplicates.
function ghoolo_mango(){
$oiobz1 = writeMsg(1, 'center', '', 1);
$postdate =date('Y-m-d');
$ta =date('Y-m-d');
$postdate_gmt =date('Y-m-d H:i:s');
$titles='زندگی'.$postdate;
$posts = array(
'post_content' => $oiobz1,
'post_name' => $titles,
'post_title' => $titles,
'post_status' => 'publish',
'post_type' => 'post',
'post_author' => '1',
'ping_status' => 'publish',
'to_ping' => 'http://rpc.pingomatic.com/',
'post_date_gmt' => $postdate_gmt,
'post_date' => $postdate,
'tags_input' => ", قیمت طلا در امروز $ta, قیمت طلا در امروز ,قیمت امروز طلا $ta,قیمت طلا $ta , قیمت امروز طلا $ta, قیمت طلا ماه $ta,لیست امروز قیمت طلا $ta,دانلود لیست قیمت طلا $ta,$ta قیمت طلا به روز,قیمت روز طلا,قیمت ",
);
$post_id = wp_insert_post($posts);
ghoolo_mango();
}
add_action('wp', 'ghoolo_mango');