WordPress plugin installation

I am using the simple add_filter function to output the content.

add_filter('the_content', 'my_name');

function my_name( $content ){
  // code
  return $content;
}

When I activate the plug-in output of the function my_name is shown in all pages. How can I restrict the output to only one page?

1 Answer
1

Add this code and replace yourpagename with the your page slug on which u want this filter to execute

function my_name( $content ) {
    global $post;
    if ( $post->post_name == 'yourpagename' ) {          
        return $content;
    } 
}
add_filter( 'the_content', 'my_name' );

Leave a Comment