Use:
if ( is_home() or ( defined( 'DOING_AJAX' ) && DOING_AJAX ) )
is_home()
returns TRUE
on the front-end only, admin-ajax.php
on the other hand is an admin page. So you need to check both conditions.
Related Posts:
- How to use add_action(‘wp_ajax_[action name]’,…) for a specific page with condition?
- Using Ajax with a Class file
- Displaying PHP Errors from admin-ajax.php
- wp_set_auth_cookie() doesn’t work in Ajax call
- SSL breaks customizer: page isn’t returned from ajax
- Stop admin-ajax?
- Is it safe to assume that a nonce may be validated more than once?
- How to verify nonce from Bulk/Quick Edit in save_post?
- store/cache ajax sent data to avoid repeated request
- wp_ajax_[service] returning 0
- Trying to load content of a post via AJAX
- Insert Post using Ajax
- How can I automatically login using a URL?
- Run again current query via ajax but changing a var
- Problems with creating sortable sections in customizer
- Quick Edit: Selected Custom Taxonomy Not Refreshing After Save
- Filter WP user acf field by ajax
- Ajax Request not coming back to class
- wp_verify_nonce always returns false when logged in as admin
- fetching via fetch/ajax gutenberg block data from third party
- Ajax requests with different WordPress Address and Site Address setup
- query vars in url work but not in ajax call
- is_home doesn’t affect content
- How to declare a JS variable in an AJAX call
- is_page() conditional not working inside an AJAX function
- How to check an ajax nonce in PHP
- jQuery Ajax passing empty parameters to my function?
- admin-ajax.php slows down, but cant figure out which plugin
- Three level taxonomy dropdown frontend
- How to solve “Updating failed” with 403 Error when trying to save a Site or Post in Gutenberg?
- Keep getting 400 Bad Request error when trying out AJAX on custom theme
- How to set post_id to 0 when you upload image via Add media button. (async-upload.php)
- How to load new text widgets and polls into the sidebar without reloading the page?
- How would you update a frontend form with AJAX
- Updating User Meta with Array on Click of Button AJAX
- Why is on status span no search results?
- eventON plugin AJAX call triggers website crash
- wp_enqueue_script() doesn’t work with AJAX
- Dynamically add more fields/remove last field in a form
- Save & Reset button in theme-option with Ajax (without refresh)
- Ajax Request for both logged and non logged users
- Ajax Multi Response Problem
- Force redirect single.php to index
- Any plugin or Script to integrate ajax selection module into WordPress page
- Custom AJAX Endpoint not returning any result
- Contact form 7 Hide response messages after 5 seconds
- how should i get json encoded data from wordpress ajax action page
- WP_Ajax Hook doesn’t execute this PHP code
- How to include php-generated javascript?
- Serve a different theme based on window size
- custom autocomplete search
- post values to custom post type which has advanced custom fields
- ajax problem – function on server is not called
- How to continuously send feedback via AJAX responses to my client?
- get current taxonomy post with ajax
- WordPress Ajax Filter
- Storing temporary data for a custom post type
- I get a 0 after the result of my ajax requests
- Not getting an ajax readystatechange on my page
- problem using ajax url
- Problems implementing Load More functionality
- admin-ajax.php error 500
- How to display contact form 7 form in vanilla js without jquery in frontend
- Error sending array data from php to javascript
- Sharing variables in both actions wp_footer and wp_ajax
- Add ajax to plugin in admin area
- Search live Ajax
- Ajax login fails: script sets cookies, but is_user_logged_in() returns false
- Using wp_send_json_success instead of $result[‘message’], die, etc
- do_action won’t work in ajax callback
- Opening Modal popup on Ajax form submission
- Ajax sometimes work and sometimes just don’t work
- 400 Bad request while submitting form using AJAX
- AJAX POST Value not being returned – WordPress – AutoTrader API
- Its possible to ajax update the content of the admin custom post type list
- WordPress custom ajax login not working on mobile browsers
- Failed to load resource: the server responded with a status of 404 (Not Found) admin-ajax.php
- Javascript output now showing in custom widget
- Ajax call on class returns old data
- how to enable ajax on submitting of contact form 7?
- Create a post with REST API and adding a category
- delete post meta data in array WordPress
- Using AJAX on Contact-form the WordPress way
- Retrieve Header Background Image with AJAX
- How to block search engines indexing certain AJAX actions
- Error while submitting form using AJAX and php
- AJAX call in backend results in empty update_option
- Ajax Comment: Page reloads whenever the comment submission form is reloaded
- How to fetch meta_value and meta_key in matrix after ajax request by post_id
- wp_ajax_action, wp_ajax_nopriv_action not working
- get_comments() returns empty array if called through AJAX
- register_setting and AJAX?
- How to get parent comment’s id?
- Static var overwritten with WP AJAX action, works fine without AJAX
- ajax response is 0 instead of ‘script’ [duplicate]
- A refreshless WordPress website
- Dynamic dependent select box getting null value
- get_template_part() does not render after the ajax request
- Front-end ajax problem all users and guests getting a 302 redirect when accessing wp-admin/admin-ajax.php
- Use Ajax to get an Options Settings Value