I have a plugin which uses this shortcode: [daisy]

And the html output of this shortcode is : <a class="clickable">Click Here</a>

Plugin is working perfect if I use the shortcode to trigger the plugin. It works with this also: <?php echo do_shortcode('[daisy]'); ?>

Normally it should work also with the <a class="clickable">Click Here</a> but it's not working, the link appears but if I click on it nothing happens.

I want to use the html output because my website is using a lot of javascript for displaying html content I cannot use php shortcodes inside javascript/jquery functions.

So, do you have any suggestions for this issue? Because I think the shortcode should work also with the html output which triggers that plugin (in my case is a contact form popup) Thanks! Later edit: This is the javascript which triggers the plugin:

<script type="text/javascript">
    // Init Plugin
        'style' : '<?php echo $wp_cpup_theme; ?>',
        'bgcolor' : '<?php echo $wp_cpup_color; ?>',
        'formelement' : '#Form_PopContactUs',
        'effect' : '<?php echo $wp_cpup_effect; ?>',
        'header' : '<?php echo $wp_cpup_popup_title; ?>'

  • Is this a plugin you wrote or one from someone else?
    – Pippin
    Commented Sep 1, 2012 at 14:54
  • from someone else...
    – agis
    Commented Sep 1, 2012 at 17:03
  • Can you please tell us what plugin it is? Most likely it doesn't work because the short code triggers some javascript to load, which doesn't happen when just using the HTML.
    – Pippin
    Commented Sep 1, 2012 at 17:08
  • this is the plugin, and yes I think it triggers some javascript, so is impossible to use just the html of the shortcode?
    – agis
    Commented Sep 1, 2012 at 17:27
  • 1
    Ugh, there is a lot wrong with that plugin. In this case, with the way it is built, you will not be able to use it with just the HTML, not unless you rewrite half the plugin to begin with. Sorry.
    – Pippin
    Commented Sep 2, 2012 at 2:14

1 Answer 1


If you open the plugin file and find where the function add_shortcode('daisy','someotherfunction'); is, then you could simply call that function that the shortcode is pointing too.

This code could be placed as follows in a plugin or the functions.php file of your theme:

add_action( 'admin_init', 'daisy_fun' );

function daisy_fun(){
        <script type="text/javascript" defer="defer">
                        var daisyLink = '<?php echo wp_contact_popup_short_code_handler(); ?>';
  • Yes, but as far as I know this is impossible, because you cannot put php function inside jquery because php is a server-side language
    – agis
    Commented Sep 1, 2012 at 18:35
  • You should always use jQuery in noConflict mode when using it in WordPress. So use jQuery(document).ready(function($){, otherwise it will result in conflicts.
    – Pippin
    Commented Sep 1, 2012 at 19:42
  • In regards to using PHP in JS, yes, you can do it, but only if the JS is placed inline within a PHP file.
    – Pippin
    Commented Sep 1, 2012 at 19:43
  • Could you please give me an example of how can I do this in my scenario? Thank you !
    – agis
    Commented Sep 1, 2012 at 20:14
  • I changed the $ into jQuery. But I do want to note that when using a $, I always surround my script with (function ($) {})(jQuery); Commented Sep 2, 2012 at 19:58

Your Answer

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

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