The function wp_localize_script() is used to send variables to a script that has already been registered and enqueued. Do you have a js file that has been registered and enqueued and has the handle of ‘ajax_URL’? If not, then that explains why it isn’t working.
Also, ajaxurl is already a js variable that is accessible via any scripts you enqueue, so I’m not quite sure what you’re trying to do here.
If you’re just trying to add a new js file into your theme, you want to look at the wp_enqueue_script() function.
Related Posts:
- In a WordPress plugin, how do you output HTML code inside the DOM header? [closed]
- Generate
- How do you completely remove the default header and footer using functions.php?
- Generating rel=prev and rel=next only on wordpress categories
- Get Current User info using wp_localize_script, in functions.php
- Passing a variable via wp_head and then calling it on the page
- New custom menu created. how to apply it?
- localize_script but data changes dependent on product ID
- Using wp_localize_script in template file – is it secure?
- Pass max posts to Javascript
- save_post hook – headers already sent?
- Init hook for header send
- Echo a div to header.php from functions.php
- What’s the difference between home_url() and site_url()
- remove_action on after_setup_theme not working from child theme
- Remove type attribute from script and style tags added by WordPress
- When should you, and when should you not, use wp_list_pluck()?
- Difference between the_permalink() and get_permalink() function
- WordPress Enqueue for homepage only, functions.php, wp-framework
- Can the new 4.8v text widget visual editor be removed?
- Which WP functions do you need to use esc_html() or esc_url() on?
- Include PHP file in Content using [shortcode]
- How to show product SKU on product page
- How to get the image EXIF date/time and use it for the WP post date/time
- Gettext details
- Is it possible to remove the main rich Text box editor?
- Add action hook conditionally – only when home.php in use
- Shortcode producing headers already sent error
- Enqueue Script with data attributes
- How to manually activate user in dashboard only by admin
- Calling a function from functions.php in header [closed]
- delete uploaded file
- How to reduce original image quality on upload?
- In WooCommerce I need to modify the thankyou.php page [closed]
- How to use get_media_embedded_in_content function
- Shortcode with parameters inside parameters
- When is wp_trim_excerpt() called?
- Dynamically add sub-categories to any category in the menu
- Is there a way to push javascript or css ‘on-page’ in a template via functions.php
- What is wrong with this Shortcode? I get it in a wrong place inside the content
- Create thumbnail on PDF upload with Gravity Forms
- gform_after_submission content appears immediately after , not in post body [closed]
- Adding Google Analytics to footer selectively
- How to change a certain text or term of WordPress into a custom into the whole site?
- Unregister Nav Menu with fallback?
- Different functions file for each site in multisite installation?
- jQuery plugin function is not a function
- I changed “Howdy” in the admin bar in the dashboard, but when I’m viewing the site it still says Howdy!
- Template tags vs get_template_part() vs functions.php
- Changes to functions.php not working
- Insert width & height attributes to all images displayed on each page
- Enqueuing Script in functions.php vs on the page
- Allowing SVG uploads in media uploader without plug-in
- Custom excerpt legnths for specific pages
- Custom logo sizes for multiple logos
- How to Add a Random Custom Gravatar in the WordPress Comments?
- Remove default user registration, login and subscriber profiles
- How to load some jquery code to make validation in the theme customizer?
- how to change link of some wordpress pages
- Ajax call theme functions from front
- Loop (iterate) through Multi-Site sub-sites (blogs)?
- Proper way of using functions in action hook?
- Custom function for specific user role
- Add custom image size not working
- When to use an if statement after get_posts?
- Programmatically Create Category and sub Category
- How to mass-delete inline styles in WordPress custom post type automatically?
- What does the author_nicename parameter do in get_author_posts_url()?
- Members only site – still need the lost password page accessible
- Load JS Script only for custom post types
- Include files in child themes, declare in functions.php
- Hook specific functions if on a specific admin page
- wp_get_attachment_image function size argument not working if I also add a custom class
- Display first name of logged in user?
- How to overwrite / extent wordpress function is_email
- WordPress upload_mimes not working for front-end uploads of 3D files
- functions.php mistakenly deleted
- Identical custom taxonomy slugs for same hierarchical children
- How do I customize my wordpress Admin Area?
- Add caption functionality to custom WordPress theme
- Not sure if enqueuing js scripts properly
- Shortcode inserts paragraphs before and after executing shortcode
- Get_template_part inside a folder
- Passing values from a widget to a function within a plugin
- User meta and author meta
- List all-childpages on parent-page AND list child-pages on childpage itself but not the current one?
- Removing permalink from post thumb in twentyeleven
- Contact Form 7 – Delay auto responds
- add code in functions.php will slow down the Execution speed?
- Sorting table function default
- Product object returns no sale price
- How to stop twenty fifteen theme from cropping featured images?
- Custom Post excerpt not working correctly
- Custom Nav Walker sub-menu
- Replace a menu with widget or a custom template file programmatically
- Wait a result before enqueue
- How do I remove the date and category form my portfolio pages
- Default Custom Field Value Automatically Update
- meta tags doesnt fetch data from permalinks
- Get list of all custom tanonomy id