• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Getting error when Trying to display custom block

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Genesis Custom Blocks › Getting error when Trying to display custom block

This topic is: not resolved

Tagged: Genesis Custom Blocks

  • This topic has 4 replies, 3 voices, and was last updated 1 month, 2 weeks ago by Michaelmati.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • March 21, 2022 at 4:55 pm #504867
    chiller
    Participant

    Hey Everyone,

    I am working on setting up a custom block with Genesis Custom Blocks. I have the block front end configured and my php build out on the backend. When I go to preview the block or add it to any page I get the following error

    Error loading block: The response is not a valid JSON response.

    I am using the following:

    Theme: Custom theme using Sage 10 Framework
    PHP: 7.4.28
    WordPress: 5.9.2

    Plugins Installed:
    - Acorn (for Sage 10)
    - Genesis Custom Blocks

    Below is a copy of my backend code

    
    <div class="hero-block">
    
        <div class="hero-block__left">
            <?php if($block_field('pre-header-text')) : ?>
                <div class="hero-block__pre-header">
                    <?php $block_field('pre-header-text'); ?>
                </div>
            <?php endif; ?>
            
            <?php if($block_field('header-text')) : ?>
                <h1 class="hero-block__header">
                    <?php $block_field('header-text'); ?>
                </h1>
            <?php endif; ?>
    
            <?php if($block_field('body-text')) : ?>
                <p class="hero-block__body">
                    <?php $block_field('body-text'); ?>
                </p>
            <?php endif; ?>
    
            <?php if($block_field('call-to-action-text')) : ?>
                <a href="<?php $block_field('call-to-action-link'); ?>" class="hero-block__cta-link">
                    <?php $block_field('call-to-action-text'); ?>
                </a>
            <?php endif; ?>
        </div>
    
        <div class="hero-block__right">
            <?php if($block_field('hero-image')) : ?>
                <img src="<?php $block_field('hero-image'); ?>" alt="<?php $block_field('hero-image-alt'); ?>" />
            <?php endif; ?>
        </div>
        
    </div>
    
    March 21, 2022 at 5:53 pm #504868
    chiller
    Participant

    Figured it out, my PHP was bad. DOH...

    May 15, 2022 at 6:43 pm #505248
    Lincoln3749
    Participant

    Yeah, You are right I am also facing some errors while using some custom blocks on genesis theme. As I have developed a script by my developer for android apps site. But when I apply it so it shows some error. Have your found the solution. Kindly share your experience if you have found solution.

    July 20, 2022 at 5:04 am #505576
    warnersmith
    Participant

    PHP Ternary Operator It Might Help You.

    December 9, 2022 at 9:43 am #506315
    Michaelmati
    Participant

    This error likely indicates that there is an issue in the php build out for the custom block. It is possible that the JSON response is not formed correctly or that there is an issue in the way the data is being retrieved from the database. If the JSON response is valid, then it may be possible that there is an issue with the way the data is being passed from the back end to the front end. It is best to debug the code line by line to determine the source of the error and make any necessary corrections.

    I am facing this error on my website dentclub.co.uk and now ill fix by applying this.

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Log In

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble