• Resolved ostrunk

    (@ostrunk)


    Hi everybody,

    I got a small problem with a filter I want to add to the output of my content. I have the following function for replacing some quotes (added a space in the entitys so the comment system doesn’t interpret my code as HTML):

    function removesmartquotes($content) {
         $content = str_replace('&# 8220;', '& laquo;', $content);
         $content = str_replace('&# 8221;', '& raquo;', $content);
         $content = str_replace('&# 8216;', '& lsaquo;', $content);
         $content = str_replace('&# 8217;', '& rsaquo;', $content);
    
         return $content;
    }
    add_filter('the_content', 'removesmartquotes');
    add_filter('the_title', 'removesmartquotes');
    add_filter('wp_title', 'removesmartquotes');
    add_filter('comment_text', 'removesmartquotes');
    add_filter('the_excerpt', 'removesmartquotes');

    Since I’m generating a pdf from the output, I use

    $post = get_post($_POST['postid']);

    and after that

    $post->post_content
    $post->post_title

    etc. to display the content. The output auf post_content is fine (the quotes are beeing replaced), but post_title remains with the standard-quotes. Is there a special filter I have to apply and if so, on which function?

    Tl;dr: I want to replace a HTML entity but $post->post_title still shows the initial value.

    Kind regards

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘add_filter doesn't work for post_title’ is closed to new replies.