I’m guessing this is a really dumb question, but I’m far more familiar with PHP/WordPress and I’m just getting started with jQuery so I’m not even sure what to search on. Is there a way to pass the output of

echo get_blogifo('siteurl')

To jQuery? I’m trying to get this to work:

$('a.getstarted').attr('href', '<?php echo get_bloginfo('siteurl'); ?>/payroll-deduction-authorization/?plan=basic');

Thanks in advance for your help!

1 Answer
1

Use wp_localize_script() to pass variables to the front end so that you can pick them by javascript.

Use it like this:

wp_enqueue_script( 'some_handle' );
$data = array( 'some_string' => __( 'Some string to translate' ) );
wp_localize_script( 'some_handle', 'object_name', $data );

And pick it up like object_name.some_string in javascript code.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *