0

I have a fairly complicated shortcode that works well when put inside the wysiwyg editor. Now I try to include this in a template PHP file using do_shortcode but it doesn't work.

My used but not working PHP source code is:

<?php echo do_shortcode('[gfchartsreports include="28" type="bar" chart_js_options="title: {display: true, text: 'Titletext', fontSize:12,fontFamily:'Arial',fontColor:"#000",fontStyle:"bold",padding:20}" custom_search_criteria='{"status":"active","field_filters":{"0":{"key":"created_by","value":"current"}}}']'); ?>

I'm not a PHP pro and so I guess the error will be a beginner's mistake. Could anyone help me out with his coding wisdom?

Thank's a lot for your help!

  • What error are you getting? – Laxmana Apr 30 '17 at 11:25
1

I think you need to escape the quotes:

<?php echo do_shortcode('[gfchartsreports include="28" type="bar" chart_js_options="title: {display: true, text: \'Titletext\', fontSize:12,fontFamily:\'Arial\',fontColor:"#000",fontStyle:"bold",padding:20}" custom_search_criteria=\'{"status":"active","field_filters":{"0":{"key":"created_by","value":"current"}}}\']'); ?>
  • Thank you Abdul! This was exactly what I was looking for. Helpful and educational. And best of all: it works ;-) – bushrang Apr 30 '17 at 11:36

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.