how to remove a content from a post?

so I use the following code to show audio player in a page which shows all the posts:

$posts = get_posts();
if(is_page())
{
foreach( $posts as $item)
{

$post_id1 = $item->ID;
$file_id1 = get_post_meta($post_id1, ‘sound_s_’, true);
$file_url1 = wp_get_attachment_url( $file_id1 );
$attr = array(
‘src’ => $file_url1,
‘loop’ => ”,
‘autoplay’ => ”,
‘preload’ => ‘none’
);

$my_post = array(
‘ID’ => $post_id1,
‘post_title’ => get_the_title($post_id1),
‘post_content’ => wp_audio_shortcode( $attr ),
);

wp_update_post( $my_post );

}
}

but the problem is that when I open the page itself I get two audio players shown. So please tell me a solution for removing audio player when It’s a post.

Read more here:: how to remove a content from a post?

Leave a Reply

Your email address will not be published. Required fields are marked *