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
- Retrieve POST data from AJAX call
- WordPress Ajax always returns a 404 error
- problem with ajax and the path to the php page
- How to use wp_localize_script in a WordPress page other than functions.php?
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- How to stop loading multiple copies of jquery
- How to Populate the list of custom post type categories
- Php string not working in WordPress Functions.php [duplicate]
- Update WordPress Custom Field with AJAX on cached page
- Targeting single page with JS
- JS completely stopped loading but Files are found
- User Defined order on get_categories?
- Categories Template Assistance
- Problems with function on function.php
- Use template for posts with a particular category grandparent
- Click loads template via ajax
- How to retrieve the content (with a specific ID) via ajax by clicking a link tag
- Loading jQuery in the footer after removing jQuery migrate?
- Returning a value from a PHP page
- Sending jsPDF documents to the server
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- Custom category code not showing all posts
- js file in root loading without
- WooCommerce – Reset quantity input field when variation changes
- Checking for new message using AJAX and PHP. Server overload?
- jQuery not defined
- Adding Custom Slider
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Change “add to cart” button color based on Woocommerce product category [closed]
- Ajax request returns ‘Array’. How to output the actual results?
- Slick + PHP + ACF + JQuery slide reveal not working
- Let Users Choose Post Categories
- Show success or error messages in Ajax response to WordPress custom registration form
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Fancybox type popup window that’s not an iframe
- Can I use a jQuery Ajax request in Code Snippets Plugin for WordPress?
- Form Security: nonce vs. jQuery
- Display most popular posts of category
- get taxonomy thumbnail and use it as a variable in code
- What are the advantages/disadvantages of using jQuery DOM manipulation as opposed to PHP DOM manipulation?
- Is it save to use eval for a jQuery callback method coming from the database?
- WordPress plugin admin page – using WordPress function in linked php file
- Use get() method to grab all categories and output inside another method
- Only show size attributes in product box woocommerce when available
- A $_POST should occur when submit form but is not?
- Argument for if term-> have child?
- Shortcode to pull posts
- Echoing a CSS class based on category of post in a list
- How to add post thumbnail dynamically using Jquery?
- calling function in external js file
- How to refresh a page from jquery [closed]
- Showing Subcategory Name/Link Instead of Parent Category
- WordPress custom taxonomy
- Finding and removing duplicates within WP Arrays
- Using multiple variables to assign categories to an array
- displaying the categories post
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- Execute PHP code only with specific user role
- Pagination at category doesnt work with same name of page
- Tracking Visitor LatLng with WordPress using JS, PHP. How to put data which was extract using JS into DB
- display the months of a specific category
- Child-Theme Category View with modified permalinks (%category% removed)
- Admin-ajax.php 404 error
- How to pass values from one function to the other using an array variable
- How to move a post from one category to another
- Update $wpdb query with AJAX
- Create category after theme setup and modify the default one
- AJAX to add to cart multiple products woocommerce
- WordPress ajax filter returning all posts when it should be filtering by category
- Let user select the number of posts shown per page jquery error
- Displaying 3 Category Posts differently
- ACF + WP + Slick Slider Repeater Slide Group PHP not Displaying [closed]
- Default Image not showing up in Customizer for WP_Customize_Cropped_Image_Control
- How to create a radio button to alt between settings in wp_options table
- How to list categories by page id in wordpress
- WordPress AJAX load post metadata in modal
- WordPress using get_term to retreive slug not working as expected
- Showing the project type in HREF
- Front end post submissions do not get submitted in the category
- How can I correctly POST to a WordPress page?
- Adding instant search to wordpress page
- Saving category as insert post
- Trying to exclude posts from a category on the home page
- Showing Subcategory’s Name and Link Instead of Parent Category’s
- What is the best way to get the first few post from WordPress in different divs using a loop?
- reorder a WP_Query, using a dropdown
- Edit Image/Image Details – Replace button missing
- on category page get name of category as a string
- WordPress categories not working throughout site
- Remove /category/ from category (archive) page URLs (without using a plugin)
- Use ajax response in PHP function
- JSON Object Value Show Undefine
- Different behaviour between “include_once” and directly echoing out html code?
- How to use js variable to php in wordpress functions.php
- ajax problems on loading page [closed]