• Resolved troventrip

    (@troventrip)


    Hi,

    I’ve created a textarea custom block and have set it to be automatically shown when creating a new custom post type (along with the core paragrapgh and videopress blocks) using the code shown at the end of the post. This works great when I enter some Default Value text in the field settings for the custom block, however if I only enter Placeholder Text and leave the Default Value empty, then the block does not show on the page. I want to use this block as a help guide (I have a multi-author website) and so the Default Value approach isn’t suitable as this requires the authors to remember to delete the block before publishing (otherwise this shows on the frontend), whereas the Placeholder Text would allow the authors to just publish and then nothing would show for the custom block when published.

    So to my question; is it possible to make the block appear with just the PlaceHolder Text entered and Default Value being empty? Or is there a way to make the custom block only visible in the Gutenberg editor screen and not be shown on the frontend when published? Either solution would work please.

    Hope the above makes sense and thanks in advance for any help!

    Code to initialize the custom block on the custom post template:
    function vlog_template() {
    $post_type_object = get_post_type_object( ‘vlog’ );
    $post_type_object->template = array(
    array( ‘genesis-custom-blocks/vlog-introduction’ ),
    array( ‘core/paragraph’ ),
    array( ‘core-embed/videopress’ ),
    );
    }
    add_action( ‘init’, ‘vlog_template’ );

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Ryan Kienstra

    (@ryankienstra)

    Hi @troventrip,
    Thanks for asking about this, sorry for the delay.

    Or is there a way to make the custom block only visible in the Gutenberg editor screen and not be shown on the frontend when published?

    If the block’s PHP template doesn’t output anything, like a blank PHP file, that should prevent it from displaying on the front end. Would that work?

    Thread Starter troventrip

    (@troventrip)

    Hi @ryankienstra Yes that sounds like it will work, let me give that a try. Thanks for your help!

    Plugin Contributor Ryan Kienstra

    (@ryankienstra)

    Of course! Hope it works.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Placeholder Text vs. Default Value Field Settings Visibility’ is closed to new replies.