[Support request] Hero block using the new block element

Home Forums Support [Support request] Hero block using the new block element

Home Forums Support Hero block using the new block element

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1494888
    Lox

    Hello,

    I am trying to build a hero block for every page but home page. I need it to use the current post feature image as background (with a fallback to a default image) and the post title. {{post_title}} isn’t working in a block element.

    Did I miss something ?

    Regards.

    #1494896
    Elvin
    Staff
    Customer Support

    Hi,

    To clarify: Are you trying to use the Block Element as a page-hero section alternative to Header Element?

    If yes, {{post_title}} is not the way to go as it will only work on Header Element.

    To work on Block Elements (Gutenberg Editor), you’ll have to find a way to make a block display the post title.

    One way to do that is through making your own shortcode.

    Here’s an example of a PHP snippet displaying post title w/ [post_title] shortcode.

    add_shortcode( 'post_title', function() {
        ob_start();
        // Start your PHP below
      	echo get_the_title(get_the_id());
        // End your PHP above
        return ob_get_clean();
    } );

    Other alternatives may require installing additional plugins that add dynamic text blocks to Gutenberg Editor.

    #1494919
    Lox

    Ok thanks.

    What about using the feature image of the current post as background for the container block ?

    Something like this would be awesome and easy to implement:

    #1495181
    David
    Staff
    Customer Support

    Hi there,

    featured images are planned for a future update where the Block Element will support dynamic content.

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