Hide parts of the post content on the home page

If your video is pasted into the post body, you have a couple of options.

  1. Use a filter on the_content and preg_replace to remove the content.
  2. Wrap your content in a shortcode.

I am going to recommend option #2 because option #1 involves processing markup with regex which is tricky and prone to error, and your question does not contain enough information for me to be able to write that anyway.

function hide_on_home_page_wpse_97587($atts,$content) {
  if (!is_home()) {
    return $content;
  }
}
add_shortcode('nohome','hide_on_home_page_wpse_97587');

Then when you post content put the switched content between [nohome] and [/nohome]

Leave a Comment