Advertisement
bedas

H-Code Archive filter

Dec 12th, 2019
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. add_filter('the_content', 'hcode_trim_excerpts');
  2. if ( ! function_exists( 'hcode_trim_excerpts' ) ) {
  3.     function hcode_trim_excerpts($content = false) {
  4.         global $post;
  5.        
  6.         //ADDING HERE A FURTHER CHECK !has_wpv_wp_archive() is solving the issue. TS NOTE.//
  7.         if( !is_singular() && !is_admin()){
  8.  
  9.             //THIS IS THE PROBLEM LINE, where H-Code replaces THE Content with excerpt. TS NOTE.//
  10.             $content = $post->post_excerpt;
  11.             // If an excerpt is set in the Optional Excerpt box
  12.             if( $content ) {
  13.                 $content = apply_filters('the_excerpt', $content);
  14.  
  15.             } else {
  16.                 $content = $post->post_content;
  17.             }
  18.         }
  19.         $content = str_replace( "|br|", "<br>", $content );
  20.         // Make sure to return the content
  21.         return $content;
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement