shortcode doesn’t work
Instead of using the shortcode in the editor, there is a function that executes the shortcode which you can use directly in php of the template for any page. <?php echo do_shortcode(‘[contact_form]’); ?>
Instead of using the shortcode in the editor, there is a function that executes the shortcode which you can use directly in php of the template for any page. <?php echo do_shortcode(‘[contact_form]’); ?>
You’re getting the output there because dynamic_sidebar() displays/echoes the output (widgets in the specific sidebar), so the output is echoed right when the shortcode function is called, which is before the $data is actually echoed. And you can fix that using output buffering: Either append the output to $data: $data.='</div>’; $data.='<div class=”col-xl-4 col-lg-4 col-md-4 col-sm-12 … Read more
echo (‘<div onClick=”ga(‘send’, ‘event’, ‘will-ich-haben’, ‘klick’, ‘test-klick’);”>’); I haven’t looked any further but as a first step, this string isn’t concatenated correctly. echo “<div onClick=’ga(‘send’, ‘event’, ‘will-ich-haben’, ‘klick’, ‘test-klick’)’></div>”;
If no attributes are used on the shortcode, then $atts will be a string, so you can’t use extract on it. Part of your problem is that you’re not using shortcode_atts correctly. You need to assign the value of shortcode_atts back to $atts. That will ensure that $atts is an array with all the correct … Read more
NEVER EVER alter any template or file in a theme or plugin that you did not author, and this goes for any core file as well. There is no way to protect the code that you alter or add in any of those files, except maybe changing file permissions, but then again, you will run … Read more
What I found to work for me was to remove the action within the foreach ending with the following code function pmc_gallery_menu_order_fix($id) { $regex_pattern = get_shortcode_regex(); preg_match (“https://wordpress.stackexchange.com/”.$regex_pattern.’/s’, stripslashes($_POST[‘content’]), $regex_matches); if ($regex_matches[2] == ‘gallery’) : $attribureStr = str_replace (” “, “&”, trim ($regex_matches[3])); $attribureStr = str_replace (‘”‘, ”, $attribureStr); $attributes = wp_parse_args ($attribureStr); endif; $ids … Read more
Shortcode handler function receives two arguments array $attr and string $content. So to pass attributes to shortcode handler function, just pass it as array: $image = route_thumb_function( array( ‘id’ => $post_id ) );
The conditional needs to test against strings which would be the name of the shortcode. If you’re looking for the [hello] shortcode the conditional would look like: echo ‘<pre>’; print_r( $shortcode_tags[‘hello’] ); echo ‘</pre>’; So if you use add_shortcode() the string you’ll be looking for is the first parameter: $tag.
Your problem is the loop itself. As others suspected, you don’t have the_content() to display the page content. Change your loop to this and that should fix your problem: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; else: ?> <p><?php _e(‘Sorry, no posts matched your … Read more
Ok mate – i got you… you should really break into 2 shortcodes. One as a wrapper (which is really short) and the other for the content… Example: add_shortcode(‘servicewrap’, ‘service_wrapsc’); function service_wrapsc($atts, $content = null) { return ‘<div class=”service”><div class=”container”><div class=”row”>’.do_shortcode($content).'</div></div></div>’; } add_shortcode(‘servicesingle’, ‘service_singlesc’); function service_singlesc($atts, $content = null) { extract(shortcode_atts(array( ‘icon’ => ‘fa-briefcase’ ), … Read more