[Resolved] Can I filter out   in content?

Home Forums Support [Resolved] Can I filter out   in content?

Home Forums Support Can I filter out   in content?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2329214
    Ben

    I have content that has   in various places. In certain areas this is causing a problem (it’s complicated but is due to Arabic font issues).

    Is there a way I can stripe this (   ) out of single content (single post page)?

    Thanks

    #2329238
    David
    Staff
    Customer Support

    Hi there,

    WordPress has the the_content filter hook:

    https://developer.wordpress.org/reference/hooks/the_content/

    You can try string replacing the &nbsp whilst in a single post with this PHP Snippet:

    add_filter( 'the_content', function( $content ) {
        if ( is_single() ) {
            $content = str_replace( "&nbsp","", $content );
        }
        return $content;
    }, 999, 1 );
    #2329308
    Ben

    nice one, many thanks, tweaked it a bit to swap for a normal space and include the semi-colon

    add_filter( 'the_content', function( $content ) {
        if ( is_single() ) {
            $content = str_replace( " "," ", $content );
        }
        return $content;
    }, 999, 1 );
    #2329327
    David
    Staff
    Customer Support

    Glad to be of help

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.