Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. // Add the filter to manage the p tags
  2. add_filter( 'the_content', 'wti_remove_autop_for_image', 0 );
  3.  
  4. function wti_remove_autop_for_image( $content )
  5. {
  6. global $post;
  7.  
  8. // Check for single page and image post type and remove
  9. if ( is_single() && $post->post_type == 'image' )
  10. remove_filter('the_content', 'wpautop');
  11.  
  12. return $content;
  13. }
  14.  
  15. $imageContent = get_the_content();
  16. $stripped = strip_tags($imageContent, '<p> <a>'); //replace <p> and <a> with whatever tags you want to keep after the strip
  17. echo $stripped;
  18.  
  19. remove_filter( 'the_content', 'wpautop' );
  20.  
  21. remove_filter( 'the_excerpt', 'wpautop' );
  22.  
  23. <?php remove_filter ('the_content', 'wpautop'); ?>
  24.  
  25. add_filter( 'the_content', 'remove_autop_for_image', 0 );
  26.  
  27. function remove_autop_for_image( $content ) {
  28. global $post;
  29.  
  30. if ( is_singular('image'))
  31. remove_filter('the_content', 'wpautop');
  32.  
  33. return $content;
  34. }
  35.  
  36. p:empty {
  37. display: none;
  38. }
  39.  
  40. .single-post .entry-content p:empty { display: none; }
  41.  
  42. .single-format-image .entry-content p:empty { display: none; }
  43.  
  44. <?php remove_filter ('the_content', 'wpautop'); the_content(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement