• Resolved memo91

    (@memo91)


    Hi,

    I have an issue with the toggle field,

    I can’t understand the logic with the example in github, and I cannot display the toggle button properly

    <?php
    $class = ‘container’;
    if ( block_value( ‘full-width’ ) ) {
    echo $class .= ‘ full-width’;
    }
    <div class=”<?php echo $class; ?>”>
    </div>
    ?>

    Could you please try to show an example or give more information ?

    Thanks in advance

    Note : Your plugin is awesome ??

Viewing 1 replies (of 1 total)
  • Plugin Author Luke Carbis

    (@lukecarbis)

    Thanks @memo91! We did a big update of the docs on Github about a week ago, so you may find that the updates there might help.

    I’m not 100% sure what you’re trying to achieve when you say you “cannot display the toggle button”. The toggle button isn’t intended for frontend output, but rather, to decide whether something should be output or not.

    So suppose you were creating a “Movie Review” block, wanted your block to optionally display the text “Verified Critic” at the bottom of the block.

    You would start by giving your block a toggle field named “verified”. Then when you add the block to a post, you decide whether the text should be displayed or not, but using the Toggle button in the editor.

    Lastly, your template would look something like:
    `
    <?php
    if ( block_value( ‘verified’ ) ) {
    echo ‘Verified Critic’;
    }
    ?>

    `

    At least, that’s it in the most basic form. Hope that helps!

Viewing 1 replies (of 1 total)
  • The topic ‘Use of Toggle field’ is closed to new replies.