• Resolved alexWP333

    (@alexwp333)


    With someone’s help, I added CMB2 to my theme, and to my functions.php file.

    I was also able to get the CMB2’s “Test wysiwyg” metabox to display content on my web page.

    However, when using the h1, h2, h3, p,. . . etc. dropdown on the CMB2 “Test wysiwyg” metabox to format my text, I’m seeing that, instead of formatting the word as, say, an h1 header, it’s literally adding in the <h1> tags to the word itself, and displaying these tags on the web page. Similarly, when I select the bold or italics buttons, the result is that I see the and tags appear on the web page itself.

    Can someone advise me as to how to get this CMB2 “Test wysiwyg” metabox to work?

    PS:I’m hosting the site locally, so can’t provide a url.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Sounds like the HTML is getting escaped/encoded before display.

    Can’t quite recall where, at the moment, we have any resources on how to properly allow html through.

    Thread Starter alexWP333

    (@alexwp333)

    If it’s any help, this is the bit that I’ve placed in my page template:

    <?php
    $text  = get_post_meta( get_the_ID(), 'alexprefix_textsmall', true );
    $wizzywig  = get_post_meta( get_the_ID(), 'alexprefix_wysiwyg', true );
    echo esc_html( $text );
    echo esc_html( $wizzywig );
    ?>

    Maybe, I should be using something other than esc_html for my wizzywig variable?

    Thread Starter alexWP333

    (@alexwp333)

    I’m also looking at this link to see if there’s anything related to wysiwyg.

    https://codex.www.ads-software.com/Data_Validation

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I’d check out wp_kses_post() which should allow through the same html markup that the post editor allows.

    Thread Starter alexWP333

    (@alexwp333)

    This got it the h1, h2, … formatting (as well as italics, and bold styling) to work.

    The only thing now is that the paragraph returns that I make in the metabox aren’t displaying as separate lines of text on the web page.

    Is there some kind of separate procedure for getting these paragraph returns to work?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    pass it through wpautop() as well then.

    Thread Starter alexWP333

    (@alexwp333)

    This is what I have so far:

    echo wp_kses_post( $wizzywig );
    echo wpautop( $wizzywig );

    Each of these lines of code, on their own, are doing exactly what I was hoping they would do, but the fact that I’m echoing it twice is giving me two set of duplicate text on the web page. Can you tell me what the correct syntax is for passing it through both the wp_kses_post() and the wpautop() using only a single echo?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    echo wpautop( wp_kses_post( $wizzywig ) );
    
    Thread Starter alexWP333

    (@alexwp333)

    It’s working fine now. Thanks for all of your help!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Test WYSIWYG Not Formatting as it Should’ is closed to new replies.