Use wp_localize_script
to pass PHP data to Javascript. Store the result in a variable by setting the echo
parameter of wp_list_categories()
to false
, and then pass the variable in the object you send to javascript through wp_localize_script
.
On a side note, I am not sure why you are having this problem at all, honestly: can you not hide your dropdowns with CSS? Or even detach
them with jQuery on jQuery(document).ready()
, to reapply them when you need them?
Related Posts:
- hover image appears below placeholder instead of overlayed
- combine Code 1 with Code 2
- Proper syntax or method for keeping url in modified isotope / category links
- Pass Category Name, Description and Photo into variables to pass to jQuery
- How to change links in the 3 main categories, on widget category, to a javascript function call
- Most efficient way to add javascript file to specific post and/or pages?
- How to correctly add Javascript in functions.php
- Display current category title on category page
- How can I fetch loop of post titles via AJAX?
- Pass media upload value to input field
- What does the token %1$s in WordPress represent [closed]
- Inject post (from specific category) between posts in Loop
- Retrieve POST data from AJAX call
- Combine CSS and JS files from plugins
- exclude multiple terms using get_terms() function
- Do I require the use of nonce?
- JqueryUi Dialog giving Uncaught TypeError: this._addClass is not a function error
- Detect a focus on wp_editor
- WordPress Ajax always returns a 404 error
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- Getting key value of WP_Term object in wordpress
- Jquery no more loading, load-scripts.php not found (404)
- retrieve thumbnail from post ID of best selling product in category
- Removing jQuery migrate and working with dependencies
- problem with ajax and the path to the php page
- How to use wp_localize_script in a WordPress page other than functions.php?
- Custom HTML structure in wp_list_categories
- Real time Duplicate title check
- Counting number of posts in a category and its sub categories and displaying result using shortcode
- Load custom field value into div with AJAX
- Allow authors to post only in categories they create in WordPress
- Archive listing of posts by publish year (multiple years)
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- Security – Ajax and Nonce use [closed]
- Refresh page after update_post_meta
- How to use WordPress (PHP) functions in AngularJS partials files?
- How to stop loading multiple copies of jquery
- Add custom field to attachments in a specific category
- Jquery ajax to custom php file: returning blank data
- How to Remove Parents Category Permalink from Posts
- Display all posts in current category
- jQuery functions only work on homepage
- How to Populate the list of custom post type categories
- Php string not working in WordPress Functions.php [duplicate]
- Looking to exclude blog posts from category Previous/Next buttons
- Nice scroll to wordpress
- Update WordPress Custom Field with AJAX on cached page
- How do I add a php statement to a jQuery string
- List all categories but exclude current post category on single post page
- Looking for a better way to handle an ajax script that pulls in post data on click
- Bulk Image upload and one image for each post?
- Targeting single page with JS
- Infinite-Scroll Plugin and Jetpack Infinite Scroll Plugin – Adding to “Thoughts” Theme
- JS completely stopped loading but Files are found
- How can I loop into two different DIVS without repeating the DIVs
- How to display related posts from parent category
- User Defined order on get_categories?
- How can I set custom order use this function
- Categories Template Assistance
- Can’t use get_results() in ajax query
- Remove commas from WooCommerce checkout addresses fields
- Using an Image Slider twice on the same page
- Edit category output
- Problem with WordPress Ajax form
- Error: array_map(): Argument #2
- Problems with function on function.php
- Use template for posts with a particular category grandparent
- Click loads template via ajax
- Put a link to a category round a hard coded A HREF
- Display notification only once
- How to retrieve the content (with a specific ID) via ajax by clicking a link tag
- Access/update database with jQuery
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- Check if Product is in a Specific Category in Functions.php
- Passing jQuery value using Ajax to a page template
- Custom Loop through category menu to include sub categories
- Different background-image by category
- Using wp_localize_script to store the template url into a variable to use in JS
- How to add a dynamic javascript snippet to the footer that requires jQuery
- Check if user is logged in when clicking certain links on certain pages
- Get posts with at least one category in common with current post?
- How to exclude specific category from the get_the_category(); array
- Add HTML Attributes To Anchor Tags In `wp_list_categories()` Function
- ajax_object is not defined when ajax calls the function
- How to speed up admin-ajax.php in wordpress
- Loading jQuery in the footer after removing jQuery migrate?
- JQuery not working on WordPress Admin page [closed]
- Returning a value from a PHP page
- Woocommerce – remove product from category
- Get category name from custom loop and echo it once
- Display all categories including sub categories
- Why is this Ajax not working?
- Stumped – Ajax Response Returns 0
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- Asking popup for delete post in WordPress [closed]
- Sending jsPDF documents to the server
- Use ajax from function.php
- Ajax return code 400
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- Parsing php string in jquery [closed]