Support

Account

Home Forums Gutenberg No Display on Front End

Solved

No Display on Front End

  • I followed the tutorial to register a custom field block. All my codes seem to be without errors, the block template shows in the backend but it’s not showing on the frontend.

    Here is the code register block in functions.php:

    function be_register_blocks() {
    
    	if( ! function_exists('acf_register_block') )
    		return;
    
    	acf_register_block( array(
    		'name'			=> 'custom-landing',
    		'title'			=> __( 'Custom Landing', 'customtname' ),
    		'render_template'	=> 'landing_page.php',
    		'category'		=> 'formatting',
    		'icon'			=> 'admin-users',
    		'mode'			=> 'preview',
    		'keywords'		=> array( 'landing', 'custom page', 'author' )
    	));
    
    }
    add_action('acf/init', 'be_register_blocks' );

    Here is the code I used for the CSS:

    
    function genesis_sample_enqueue_custom_styles() {
    
    wp_enqueue_style(
        'landing',
     		get_stylesheet_directory_uri() . '/lib/gutenberg/landing-custom.css',
    		array( $child_theme_slug ),
    		CHILD_THEME_VERSION
      );
    }
    
    add_action( 'enqueue_block_editor_assets', 'genesis_sample_enqueue_custom_style' );
    
    // Add supp
    add_editor_style( '/lib/gutenberg/landing-custom.css' );

    I will appreciate some help here.
    Thank you!

    • enky

    • March 11, 2019 at 10:53 pm

    Can you see some html from landing_page.php in the page itself?

    Is the html rendering and “only” the Content is not showing up ?

  • No only the page footer content. Also the html from the template is not rendering. I’ve used the same template a few times outside Gutenberg so I must be doing something wrong in Gutenberg.

    • enky

    • March 12, 2019 at 3:40 am

    Maybe the path to landing_page.php is just wrong ?

    
    render_template
    (String) The path to a template file used to render the block HTML. This can either be a relative path to a file within the active theme or a full path to any file.
    
    // Specifying a relative path within the active theme
    'render_template' => 'template-parts/block/content-testimonial.php',
    
    // Specifying an absolute path
    'render_template' => plugin_dir_path( __FILE__ ) . 'template-parts/block/content-testimonial.php',
    
    
  • Is there a difference between plugin_dir_path(__FILE__) and get_template_directory_uri ?

    I noticed that my code above was missing the path but I later added the get_template and not the plugin_dir. Perhaps I should try the other format too but not sure if it matters

    • enky

    • March 12, 2019 at 10:59 pm

    Just look in the wordpress codex. I cant tell you, how the path has to be. I dont know your wordpress / theme setup 🙂

  • Thank you again enky. The new error now is “Your site does not support the “acf/testimonial” block. You can leave this block or delete it completely.”

    Not sure if anyone has a solution to that error message.

  • Phew! After days of trying to figure out what went wrong, I finally figured it out. It’s now displaying on the front end, as expected. It turns out that my template callback function is not pointing to the right template folder. That’s it!

    Thanks envy for taking the time to help.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.