Passing variable in nested shortcodes

If I was going to be doing something like this, then I would actually build 2 shortcodes. One for the ‘boxes’ and one for the inside ‘box’. I do believe that is the only way plausable. When you build one for the outside box, just make sure to use do_shortcode(); around the content variable. If … Read more

Problem with height in video shortcode

It doesn’t seems to be a bug, but it’s designed like that only… Have a look how height variable is being changed by other parameter to keep up the right video ratio based on the theme. if ( ‘video’ === $type ) { $width = empty( $meta[‘width’] ) ? 640 : $meta[‘width’]; $height = empty( … Read more

What is this format called (nested shortcodes)?

I would use the phrase Nested Shortcodes to describe it. You can find many questions using that phrase here on WPSE. The Codex also uses it, for example here: http://codex.wordpress.org/Shortcode_API#Nested_Shortcodes Since the shortcodes in your example are related to the layout, we could perhaps call it: Nested Layout Shortcodes to be more specific. If you … Read more

Echo HTML in custom shortcode

I don’t know what “this isn’t working” means but a shortcode should not echo anything. You should concatenate a string and return it. if (is_single()){ $str=””; if($type == ‘audio’){ $str .= ‘<div class=”sub-audio”><h6 class=”sub_btn”>Audio</h6>’; } if($type == ‘video’){ $str .= ‘<div class=”sub-video”><h6 class=”sub_btn”>Video</h6>’; } foreach ( $bookmarks as $bookmark ) { $str .= sprintf( ‘<a … Read more

Basic do shortcodes question

the_field() is an ACF function and will echo content. It follows the WordPress (somewhat) pattern whereby functions with the_ at the front will echo content and functions beginning with get_ return content. Displays the value of the specified field. (this is the same as “echo get_field($field_name)”) http://www.advancedcustomfields.com/resources/functions/the_field/ Using the wrong function, as you have, will … Read more

Shortcode in my childtheme is not working

Reading your question, I think you are calling [get_employee] directly from a PHP template file in your child theme. This is not the way shortcodes work. You have three options: Put [get_employee] in the content of a post Run do_shortcode(“[get_employee]”) wherever you want in a template file Call directly the function callback wherever you want … Read more

Why can’t I display attachment_image_src with Custom Size?

With wp_get_attachment_image_src you get a array with values corresponding to the (0) url, (1) width, (2) height, and (3) scale of an image attachment (from the wordpress doc). you code can be: if($imageid){ $image_attributes = wp_get_attachment_image_src( $imageid, ‘custom-size-01’, false); echo “<img src=\””; echo $image_attributes[0]; echo “\” width=\”100%\” >”; }

shortcode issue in the_excerpt

Okay, I finally found it the answer. You need to add two filters to your functions.php file in order to run shortcodes through it. add_filter( ‘the_excerpt’, ‘shortcode_unautop’); add_filter( ‘the_excerpt’, ‘do_shortcode’);

How to trace shortcode to its functionality

What I always do is, I search the files… So I use the “Search in files”-function in Notepad++ (which I am using) and limit the search to the directory, where I think, I will find what I am looking for. So, probably, you know already the plugins directory. You enter this information into the folder … Read more

Create a shortcode to use in visual editor

Simple, make a shortcode: function my_image() { $image = get_field(‘imagen_superior’); if( !empty($image) ) { echo ‘<img src=”‘ . $image[‘url’] . ‘” alt=”‘ . $image[‘alt’] . ‘” />’; } } function my_shortcode( $attr ) { return ‘<div class=”header-image”>’ . my_image() . ‘</div>’; } add_shortcode( ‘my-shortcode’, ‘my_shortcode’ ); and then place [my-shortcode] in the visual composer.