Tejas Mehta
Tejas Mehta

Reputation: 941

Load specific css file in shortcode - wordpress

I am making one plugin which has functionality using shortcode , While shortcode will place in the page , it will return a well desgin form For example : https://www.screencast.com/t/XTteV6u8qw

Now if I add bootstrap css/classes my current theme went messed up,

I want functionality like in any theme my shortcode function display design will remain same. Any idea about how it is possible ?

Any information on this would be greatly appreciated. Thanks!

Upvotes: 0

Views: 596

Answers (1)

Kirit Patel
Kirit Patel

Reputation: 122

You could write the internal css of that shortcode content like below example.

function shortcode_func( $atts ) {

   $returnString = '<style>';
   $returnString .='#shortcode-id{background-color:yello;}';
   $returnString .= '</style>';

   $returnString .='<div id="shortcode-id"></div>';
   return $returnString;
}

add_shortcode( 'shortcode-name', 'shortcode_func' );

Upvotes: 1

Related Questions