Community Forums › Forums › Genesis Custom Blocks › Getting error when Trying to display custom block
Tagged: Genesis Custom Blocks
- This topic has 4 replies, 3 voices, and was last updated 5 months, 3 weeks ago by
Michaelmati.
-
AuthorPosts
-
March 21, 2022 at 4:55 pm #504867
chiller
ParticipantHey 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.2Plugins Installed:
- Acorn (for Sage 10)
- Genesis Custom BlocksBelow 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 #504868chiller
ParticipantFigured it out, my PHP was bad. DOH...
May 15, 2022 at 6:43 pm #505248Lincoln3749
ParticipantYeah, 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 #505576warnersmith
ParticipantPHP Ternary Operator It Might Help You.
December 9, 2022 at 9:43 am #506315Michaelmati
ParticipantThis 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.
-
AuthorPosts
- You must be logged in to reply to this topic.