Prefilling Call to Action block in a block template
-
Hi,
I’m trying to make a gutenberg block template that uses and prefills the call 2 action block.
I was able to prefill all settings in that way, and it worked except for the ctaText and perhaps the button size that didn’t respond to values like “large” and probably just need a pixel value.
Can anyone tell/show how a ctaText value can be passed to the block in a template, so it will show as content in the call 2 action block? Help is greatly appreciated.
Looking in console the ctaText is an array, but contains objects type ‘p’ and children, when I fill something in the editor. I don’t know how to address that yet in a way that it will work in templates and all my attempts until now have been unsuccessful.
The code I used to try it out is:
$wp_post_types['post']->template = array( array( 'genesis-blocks/gb-cta', array( 'buttonText' => 'Some button text', 'buttonUrl' => '#respond', 'buttonAlignment' => 'center', 'buttonBackgroundColor' => '#fff', 'buttonTextColor' => '#000', 'buttonSize' => '32', 'buttonShape' => 'round', 'buttonTarget' => true, 'ctaTitle' => array( 'This is a title' ), 'titleFontSize' => 48, 'ctaText' => array( 'This is some text' ), 'ctaTextFontSize' => 16, 'ctaWidth' => '50', 'ctaBackgroundColor' => 'red', 'ctaTextColor' => '#fff', ) ), array( 'core/paragraph' ), );
Thanks,
Hans
- The topic ‘Prefilling Call to Action block in a block template’ is closed to new replies.