is_admin()
returns true
if you’re doing an Ajax request. So this is why my code didn’t work. Instead I’ve done this:
add_filter( 'loop_start', 'my_sidebar_widget', 25 );
function my_sidebar_widget() {
if ( is_active_sidebar( 'my_sidebar' ) && (defined( 'DOING_AJAX' ) && DOING_AJAX ) || !is_admin() ) {
echo '<div id="my_sidebar">';
dynamic_sidebar('my_sidebar');
echo '</div>';
}
}
defined( 'DOING_AJAX' ) && DOING_AJAX
returns true if you’re doing an Ajax call, and !is_admin
will work if you’re not doing an Ajax request. In this way, it is not shown in the Media Admin Panel.
Related Posts:
- AJAX filter posts on click based on category
- How can I send data to admin-ajax via JS Fetch?
- Shortcodes not resolved in AJAX call response
- Ajax, filters and shortcodes
- Multiple Ajax Data Action
- Are there actions or filters I can use for Ajax calls?
- Does a plugin with a AJAX button filter exist? [closed]
- wp_mail works with add_action(‘save_post’, …) but not an ajax action
- Is it possible to bind a function to a filter hook via Ajax?
- How To Override A WooCommerce AJAX Function
- How to filter Sidebar Content
- Hook in a sidebar widget and add some markup
- Best practice: Custom Post Type / Filter / Load more
- WordPress Gutenberg core/heading block (wp-block-heading)
- Ajax filter – show all results that contain at least one filter
- AJAX Post Filter
- Display post after choice two taxonomy terms
- Ajax Filtering Pagination
- How can I add a prefix to titles displayed in sidebar using function.php?
- Change add_filter based on Ajax
- Filter posts by categories ajax is showing all the posts
- Code restricted to dashboard, running unexpectedly in the frontend (pre_get_post and admin-ajax.php)
- How do I add a class to all sidebars to let a Google Custom Search Engine know not to index the content?
- what is __return_false in filters
- How To Determine If A Filter Is Called In A Sidebar/Widget Context?
- Passing Additional Parameters to add_filter Callable
- How can I add an Author filter to the Media Library?
- Modify WordPress Rest Api Request/Response
- How to add some custom HTML into wordpress admin bar?
- Change upload directory on custom plugin page
- apply_filters(‘the_content’, $content) alternative
- How to use the_excerpt in a filter hook?
- Add wrapper to only youtube videos via embed_oembed_html filter function
- Hook into admin post list page
- Add post/page ID to inserted links within the_content
- Changing document title only on a custom page template
- Possible to filter the posts or categories that XML-RPC users see in their mobile application?
- wp_link_pages output appears twice
- How do I pass the value from a foreach loop to an add_filter function? [closed]
- Changing a WordPress core function without hacking core
- Change WordPress RSS link with filter?
- How to remove get_post_metadata using remove_filter inside a class?
- Sorting and limitation with pre_get_posts
- Warning: Missing argument 2 for widget_title filter
- Use add_filter on concatenated string variable
- Change term name only on front
- Excluding specific widgets from default sidebar class
- How do I hide the current page’s title?
- Change name of existing post status type
- How to filter meta_values using REST API
- Header image automatically changes depending on season
- Admin Backend – Search Pages only by title
- How to hide Ads in between posts on AMP? [closed]
- What is the downside of using a filter as a “poor man’s” dependency injection?
- Wrong post_status notice after wp_insert_post_data
- BBPress changing default group activity
- Comment search plugin
- Filter the_content to add something before each element?
- How to display the content HTML of a page without displaying the gallery code as well
- Filter Text from sidebar widget?
- Filter by category and city for doctors and hospitals in wordpress
- Remove Comment Author Link only for subscribers
- Prevent reset password specific user role
- Change AJAX filter from POST to GET for URL Parameters
- Why is overwriting $GLOBALS killing the_content()?
- Sorting products by price ( regular + sale price )
- Create new custom field that calculates age
- How can I edit comment meta value before it is saved?
- Why current_user_can(‘edit_comment’) always true?
- Remove comments validation (remove filter?)
- Redirect after post deleted
- Remove Site Name from wp_title WITHOUT removing from attribute
- Plugin default settings hook
- How to stop filter from running on the index.php page?
- Filter Shortcodes when using get_page
- Usage of filters
- add_filter to the_content after apply_filters
- Where exactly does the edit_{taxonomy} hook fire?
- How to filter with dropdown in backend for custom data
- Is there any reason for the nested filters to be applied on the first case and not in the second one?
- Pagination don’t work with active filters
- Redirect an archive page to its relevant URL-friendly filtered page
- Show uploaded pdf files dynamically and filter by month name
- How can I pass instance via apply_filters as a parameter?
- how to use substr with get_the_content()
- Add filter return false not working
- How to add markup to the wp-custom-header div
- How to take shortcode and content separately from a page?
- How to stop echoing gallery inside content?
- how to filter datalist table of wordpress
- Apply a filter str_replace on specific caracters array in the_content()
- get_the_archive_title hook unwanted changes!
- Is there a function to edit Blogs contents in Blogs page?
- Can’t set properly WordPress add_filter function
- apply_filters to $GLOBALS
- The title of an attachment is not working
- Removing a line from a WP core function (comment_template.php) – filter or other technique?
- Hide H1 Title using the_title filter
- Add Default WordPress Formatting To Data From External SQL Tables?
- filter a list by gender