Thank you so much, it’s working. Here is my modified code:
function wpse45436_posts_filter( $query ){
global $pagenow;
$type="post";
if (isset($_GET['post_type'])) {
$type = $_GET['post_type'];
}
if (
'post' == $type
&& is_admin()
&& $pagenow =='edit.php'
&& isset($_GET['ADMIN_FILTER_FIELD_VALUE'])
&& $_GET['ADMIN_FILTER_FIELD_VALUE'] != ''
&& $query->is_main_query()
) {
$query->query_vars['meta_key'] = 'n_de_ldition';
$query->query_vars['meta_value'] = $_GET['ADMIN_FILTER_FIELD_VALUE'];
}
}
By targetting the main query with $query->is_main_query()
we avoid modifying our get_posts()
call that we use to populate the select box. The reason is that get_posts()
is just a wrapper for the WP_Query
so the parse_query
hook can affect it as well.
Related Posts:
- Filter by custom field in custom post type on admin page
- How can I filter posts by post_parent in the admin?
- Filter by custom Field for Custom post type Admin Listing
- Unable to filter on field on edit.php page
- Admin List Dynamic Heading
- How can I add a column in the wp_list_table of the admin area?
- Add html to cpt main page / admin edit.php
- Options page – dropdown of users
- Filtering posts list table
- sortable columns for multiple custom post types not working
- Is there any filter to add a custom attribute to the tag in admin panel?
- Help Adding filter to Add Media button for custom post type
- Dropdown switching subcategories portfolio
- single-{$post_type}-{slug}.php for custom post types
- Placing a Custom Post Type Menu Above the Posts Menu Using menu_position?
- Loading External Scripts in Admin but ONLY for a Specific Post Type?
- Saving Taxonomy Terms
- Add “Last Edited by” column to custom post type list table
- Filter custom post types in admin not working
- wp_dropdown_categories in custom post type with custom taxonomy
- Create a dropdown with Custom Post Types as option in admin
- How to correctly get post type in a the_title filter
- How to add a CSS class to every image in a Custom Post Type
- Best way to filter featured image text for a custom post type?
- Prevent reload confirmation after AJAX save
- Admin Post Update Redirection to Posts Screen
- post_type_link filter causes 404 on the CPT page it’s used on
- Custom Post type sort order not working in the admin area
- Debug output during filter execution doesn’t work
- Add custom column to custom post type overview in backend
- Filter posts with ajax form and checkboxes
- How to Change the Title of a Meta Box on a Specified Custom Post Type? [duplicate]
- Help with issues on “Adding a Taxonomy Filter to Admin List for a Custom Post Type?”
- No results searching custom post type in admin panel
- Adding posts of custom type into the main feed
- Used with meta_query in query_posts works slowly
- Archive filter disappears on no results?
- Show admin help message across custom post type parent and child posts
- How to show custom (checkbox) field value in admin post list?
- Remove “Get Shortlink” button in admin of custom post type
- How to get Custom Post ID by adding filter to child theme’s function
- How do I set the link in the Custom Post Type admin menu?
- Add text to wordpress admin ‘Add Post’ edit
- Filter custom post type archive page with custom taxonomies (categories) with AJAX
- How to filter out post type meta?
- How can I change the title of an Add New page in Admin for custom post type
- How to check if “is single” page
- Set a default category – if the user didn’t select one- before creating a post
- Make a function to run only for CPTs
- Modifying date filter on admin page for custom post type to link to custom field
- Pre_get_posts filter overwrites all search functionality
- Add acf field in title (admin table)
- Append date to custom post type url slug
- Custom Post Type Nav to Subpage
- Selecting a post in Dashboard
- Multiple level category drop-down from the WordPress dashboard
- WordPress sort search results by custom order
- How can I made custom taxonomies relationship?
- WooCommerce sort products by the actual product width(not the shipping width)
- search suggest – filter post type
- CPT Validation to not show “Post updated.”
- How does the filter post_updated_messages work?
- Create new custom post and post category of same name
- Use remove_meta_box conditionally on custom post type
- How to check if post/page or taxonomy post is published by admin
- CPT Columns doesn’t show categories
- Insert Custom Post Types
- Custom Post Type – Support “author” only for admins
- How do I add custom HTML to the content of an archive page’s posts?
- Only show posts with a specific term of an associated taxonomy in a custom post type archive
- REST filters only firing when I have a param set
- Showing User’s Post Counts by Custom Post Type in the Author.php?
- Filtering the_content, but still need to display the unfiltered content inside filter
- Function to add custom HTML into head in custom post-type list page
- Create a Dropdown Selector and Redirect for a Custom Taxonomy in WordPress?
- custom filtering admin columns
- Ajax Post Filter | Split Taxonomy Into minPrice & maxPrice
- Query filter by value in meta_value array
- WP Admin Dropdown List Filter for custom (ACF) field on custom post type(s)
- Dynamic page for nav items used as filters
- Post Click Redirect to Custom URL instead of Single Post Page
- How to hide private posts even if user is admin
- Output all terms slugs for a loop filter
- How to set selected attribute on option after filter query?
- Apply pre_get_posts to specific custom post type in the admin area
- Filter between Custom Posts depending on meta_value
- Custom post type doesn’t display on admin list
- Filter wp_dropdown_categories Per Post Type
- Sorting on Taxonomy in archive page
- Shared Custom post type between WP network sites
- Filter custom post type by tags
- Custom Search Template for Custom Post Types
- WordPress Author Posts Review After Every Change In The Same WordPress Post
- Redirect preview single post link to a page
- How to output the content of a Custom Post Type from a drop down form?
- Rewrite a filter as shortcode (or something like that) to use anywhere in CPT
- add_filter > posts_where works partially
- Simple Share Buttons Add Plugin and Custom Post Type
- Issue displaying multiple TinyMCE editors with WPAlchemy
- Add post id to url instead of WordPress default -2 suffix