Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Add the filter to manage the p tags
- add_filter( 'the_content', 'wti_remove_autop_for_image', 0 );
- function wti_remove_autop_for_image( $content )
- {
- global $post;
- // Check for single page and image post type and remove
- if ( is_single() && $post->post_type == 'image' )
- remove_filter('the_content', 'wpautop');
- return $content;
- }
- $imageContent = get_the_content();
- $stripped = strip_tags($imageContent, '<p> <a>'); //replace <p> and <a> with whatever tags you want to keep after the strip
- echo $stripped;
- remove_filter( 'the_content', 'wpautop' );
- remove_filter( 'the_excerpt', 'wpautop' );
- <?php remove_filter ('the_content', 'wpautop'); ?>
- add_filter( 'the_content', 'remove_autop_for_image', 0 );
- function remove_autop_for_image( $content ) {
- global $post;
- if ( is_singular('image'))
- remove_filter('the_content', 'wpautop');
- return $content;
- }
- p:empty {
- display: none;
- }
- .single-post .entry-content p:empty { display: none; }
- .single-format-image .entry-content p:empty { display: none; }
- <?php remove_filter ('the_content', 'wpautop'); the_content(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement