0

I am currently using a theme which comes with a set of shortcodes.

I would like to include a shortcode inside a shortcode. One comes from a social share plug-in called ShareThis whilst the other is part of the theme.

However, when I nest the shortcode, it just does not work.

I have also tried this plug-in but it is not working either. The shortcode I am trying to add is below. [st_buttons] Is the shortcode i am trying to nest.

[flip_image animate='flip' delay='' flip_on_appear=''     front_image_link='' back_image_link='' background_color='#f2f2f2' back_text='[st_buttons]' link='' target='']

Update Shortcode function

if (!function_exists('flip_image')) {
function flip_image($atts, $content = null) {
extract(shortcode_atts(array("animate" => "", "flip_on_appear" => "",     "delay" =>"", "front_image_link" => "", "back_image_link" => "", "background_color" => "", "back_text" => "", "link" => "", "target" => ""), $atts));
$html = "";  

if($front_image_link != "" && $back_image_link != ""){
    $html .=  '<div class="flip_image_holder '.$animate.' '.$flip_on_appear.'" data-delay="'.$delay.'"><a href="'.$link.'" target="'.$target.'"><div class="flip_image front"><img src="'.$front_image_link.'" alt="'.getImageAltFromURL($front_image_link).'" /></div><div class="flip_image back"><div class="flip_image_text"><div class="flip_image_text_inner"><img src="'.$back_image_link.'" alt="'.getImageAltFromURL($back_image_link).'" /></div></div></div></a></div>';
} else {
    $html .=  '<div class="flip_image_holder '.$animate.' '.$flip_on_appear.'" data-delay="'.$delay.'"><a href="'.$link.'" target="'.$target.'"><div class="flip_image front"><img src="'.$front_image_link.'" alt="'.getImageAltFromURL($front_image_link).'" /></div><div class="flip_image back" style="background-color: '.$background_color.';"><div class="flip_image_text"><div class="flip_image_text_inner"><h4>'.$back_text.'</h4></div></div></div></a></div>';
}

return $html;
 }
 }
 add_shortcode('flip_image', 'flip_image');
4
  • Can I just confirm that your output ends up with back_text="[st_buttons]" with the shortcode just staying as it is? Commented Apr 4, 2016 at 14:18
  • yes that is correct the main shortcode is the [flip_image] and [st_buttons] is the shortcode. However when i insert it as above it breaks and just shows a '] on the page. Commented Apr 4, 2016 at 14:27
  • You will need to edit the first shortcode function to make sure it calls do_shortcode() with the content it gets passed through developer.wordpress.org/reference/functions/do_shortcode otherwise it just outputs it as text and you end up with [] like you said Commented Apr 4, 2016 at 14:31
  • Hi, thanks for the information, i have now updated the question with the first shortcode code like you asked, any ideas? Commented Apr 4, 2016 at 14:55

1 Answer 1

0

If you are able to update that shortcode you need to make a change where it refers to back_text and add in the do_shortcode() function:

<h4>'.do_shortcode($back_text).'</h4>

That should then run the second [st_buttons] shortcode function that you need.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi thanks for your answer for some reason that is not working and it just shows the last part of the shortcopde on the page - it just displays: link=” target=”]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.