Anyone encountered this issue?
I have created a custom php script which adds a new post by using wp_insert_post() but everytime I run the code it creates a 2 new post where in it should be only be one, its like it runs twice, so I tested another function using wpdb->query and its also the same its really weird. Please help I dont know what causes and how to fix this issue.
Thank you very much.
Here is a sample code i did just to test the issue and it still creates 2 identical post
function testtest(){
$ads_data = array(
'post_title' => "test",
'post_content' => "test",
'post_status' => 'publish',
'post_type' => 'ads',
//'post_author' => $user_id
);
// Insert the post into the database
$ads_id = wp_insert_post( $ads_data );
}add_shortcode('testtest','testtest');
SOLVED
I have figured it out now, whats causing the issue is on my header.php it is this line of code:
<link rel="icon" type="image/png" href="<?php echo esc_url( get_theme_mod( 'favicon' ) ); ?>" />
I find it really weird, i have no idea why that line of code is causing the issue, anyway thanks everyone!