1

i called wordpress function between the shorcodes as a input.

<?php echo do_shortcode('[shortcode]'.$var.'[/shortcode]');?>

how to add div class for the $var here?

I tried few combination but it works for the full shortcode. i just want to use the div only for $var.

I tried like,

<?php echo '<div class="own">', do_shortcode( '[shortcode]'.$var.'[/shortcode]'), '</div>' ; ?>

How to add div class only for $var here?

4

It's a bit difficult to understand or provide an accurate answer as we don't know what the shortcode is executing. Is it stripping html or any other parsing?

If this is your own code, then you could add it in the function the shortcode is calling.

If its not you could try a couple options:

1: (adding the div directly into the shortcode call)

<?php echo  do_shortcode( '[shortcode]<div>'.$var.'</div>[/shortcode]'), ; ?>

2: add it to the $var first:

<?php  
  $dvar = '<div class="own">'.$var.'</div>';
  echo do_shortcode('[shortcode]'.$dvar.'[/shortcode]');
?>

Again, the ideal solution would be to see that function and then put the div directly in before the shortcode is executed.

1

How to add div class only for $var here?

Try this

<?php 
     echo  do_shortcode( '[shortcode]<div class="own">'.$var.'</div>[/shortcode]'), ; 
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.