return an array with a shortcode

Shortcode should return string ready to append to content. You can’t return an array, because it won’t be printed correctly. So if your shortcode should return an array, you have to figure out how this data should be formatted. One way to do it is to use commas to separate the values: return implode( ‘, … Read more

How to use code in an editor block?

The easy way would be to create a Shortcode in the functions.php file of your theme and then use it in Gutenberg. Gutenberg has a built-in block to add shortcodes. Basically, you will add the following code to your functions.php file, function get_forum_post_information( $atts ) { // The PHP Code that you want to execute … Read more

If statement shortcode

Try this: <?php function howitworks() { $page = get_page_by_title(‘shop’); $html=””; if (have_rows(‘steps’, $page->ID)) : $html .= ‘<div class=”test”>’; while (have_rows(‘steps’, $page->ID)) : the_row(); $image = get_sub_field(‘icon’); $html .= ‘<div class=”col”> <img src=”‘.$image[‘sizes’][‘thumbnail’].'” alt=”‘.$image[‘alt’].'” title=”‘.$image[‘alt’].'” /> <h2>’.get_sub_field(‘step’).'</h2> <p>’.get_sub_field(‘description’).'</p> </div>’; endwhile; $html .= ‘</div>’; endif; return $html; } add_shortcode(‘howitworks’, ‘howitworks’); ?> EDIT: I change up my code … Read more

Gutenberg running code only available in front end within shortcode

Use it like this, this defined(‘REST_REQUEST’) will help you to disable running on the backend gutenberg block editor function generate_new_member_form() { if(defined(‘REST_REQUEST’)) return; ob_start(); ?> // a form // to generate this form there is some code that uses objects or functions // only available in the front end <?php return ob_get_clean(); } add_shortcode(‘new-member-form’, ‘generate_new_member_form’);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)