I'm using short codes of my own and I realised that it strips some html code away and messes up with what I wrote in my code.

Let's start with an example.

In Wordpress I add [myshortcode id="99"]

In PHP I have:

function myshortcode($atts)
      $my_id = $atts["id"];
      echo "<div>".$my_id."</div>";
      $content = ob_get_contents();
      return $content;

add_shortcode( 'myshortcode', 'myshortcode' );

In my log file (log.txt), I find this:


In my rendered page, I find this:


It looks like Wordpress is doing something with the output of my short code and stripping away my DIV. Links are working but html tags aren't. I also see sometimes
tags being added while it doesn't make sense.

Is there a way to prevent WP from doing this ?



Your Answer

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

Browse other questions tagged or ask your own question.