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
- Is it ok to use a function to output the text domain name in a wordpress theme
- How to override a function when isn’t at functions.php
- contactform7 remove tags with “wpcf7_autop false” from functions.php
- How to count number of functions attached to an action hook?
- Show modified time if post is actually modified
- ajax live search for post title
- Hourly Routine Not Firing ( wp_schedule_event() )
- How to get an array of menu items from the toolbar?
- Using get_terms for custom taxonomy in functions.php
- Fatal error: Call to undefined function add_action() – an untouched problem
- echo or print_r in an admin function
- Editing or filtering the output of the Genesis navigation
- Automatically Add Specified Value to Attachment Metadata upon Upload
- Twenty Eleven Child theme error when attempting to use a rewritten function
- is_plugin_active() not properly returning true
- Display gallery on top before content
- List of Body Classes Generated by body_class()
- is_dynamic_sidebar always returns true while using Jetpack visibility
- wp_trash_post function to only apply to posts, not pages!
- Redirect specific page in WordPress for first time visit
- qTranslate in functions.php
- Using Schema with `the_excerpt`
- Image rotation fails to regenerate custom sized thumbnail
- Register and load scripts
- Display alert on successful user Sign Up
- Getting different functions data while using while loop in wordpress
- How to rewrite the custom url in wordpress?
- About cron delete user with meta_key
- Set spesific size of featured images
- Excerpts are not displayed by a shortcode on category pages
- Getting comment count per post not working
- Functions.php Problem
- different style sheet for just one page template
- Problem with comments_number()
- Functions when woocommerce isn’t installed
- How to get correct value from checked()?
- Dequeue script to prevent javascript event conflict on wordpress child theme
- While loop with an exception after a count is reached
- Return child theme url
- Redefine function arguments before rendering
- Enqueue script on every page except one
- Best way to handle lack of titles in microblogging
- Upgraded server now class My_Walker_Nav_Menu extends Walker_Nav_Menu not working
- Functions php shortcode for displaying main menu with no child items
- How to include any template using Shortcode fuction?
- display a div on ervery site but not frontpage?
- first paragraph of the_content as meta description
- get_terms (or tax_query) for term of current post?
- Do we need to change our child function.php to require/include child dir files when we add an over-riding file.php into the child theme
- How to use get_posts() function in functions.php
- Child theme functions.php
- How to echo Widget Title in Custom Frontend-Template Box
- Redirect to post after publish or update a published post
- Page Template Won’t Load Correct CSS File
- WordPress show bad the php hour and date
- Using add_image_size in functions.php to get original uploaded file
- show all the posts thumbnails
- the_excerpt function not showing image
- How to display this meta data (an array) in form of a function (created with a custom write panel)?
- WordPress – using sessions?
- Use a filter for wp_robots to block CPT/feed/
- Trigger email alert if file downloaded
- Completely Disable WordPress RSS Feeds
- Order column custom date using pre_get_posts
- query_vars treat as single var from URL
- Running javascript without hooking wp_head
- Remove text after a dot and a colon in Woocommerce product title
- Selecting specific query for offset
- Enable CORS Request for hostname using IP address
- Change default color scheme in twentyfifteen child theme?
- Restrict access if logged out except for homepage
- Add meta data in head from theme
- what is `get_section()` and how to use it?
- function replace_text for entire page
- DISABLE wordpress upgrade page
- How to echo the translated custom field?
- Only Show One Category Name Per Post
- Moving CDN jQuery to footer does not work?
- Blank child theme – functions.php problem
- update_usermeta don’t work
- WP supersize not displaying when different languages flags are selected
- How do I make my child theme’s CSS update when I save it?
- Bulk set Post Title as Tag where Tag is Empty Function
- How do i set global variable in a function in wordpress functions.php
- Working function() doesn’t execute when triggered by WP CRON
- WordPress – Notice: Function wp_enqueue_script was called incorrectly
- post_row_actions filter from parent theme not executing in child theme