wp_localize_script not create variable in head section

Your code looks correct. alert(wp_ajax.nonce); should display the nonce. You can also verify the existence of the wp_ajax object via console.log(wp_ajax) in your browser’s Javascript console. wp_localize_script adds the object(s) to the footer (a call to wp_footer() should be present in the theme’s footer.php file). It’ll look like so: <script type=”text/javascript”> /* <![CDATA[ */ var … Read more

How to get $post object available inside functions.php to localize script?

The wp action hook fires pretty early, before the $post object is set. I would suggest using the appropriate hook wp_enqueue_scripts instead, and amending your code to: function profolio_localize_script () { if ( is_singular( ‘my-gallery’ ) ) { $layoutType = get_post_meta( get_queried_object_id(), ‘gallery_layout’, true ); // Rest of code } }

Passing variable data from external jQuery file to options.php

May i suggest: $(‘tr td .widget-remove a’).click(function(){ var toremove = $(this).attr(‘rel’); // Out of ideas – you shouldn’t really be for we are here! $.ajax({ type: ‘POST’, // use the method you want dataType: ‘json’, url: ajaxurl, // this is the url to the admin ajax script data: { nonce : your_script_data_object.nonce, toremove: toremove }, … Read more

help with wp_localize_script

That’s how the wp_localize_script function works. It prints all the variables before your script is included to make sure that the variables are available to the script. If you want to print the localized variables only one time, but make sure that they are accessible for all three scripts – you can do that by … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)