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
- How to add a post slug to a url?
- On update or create post redirect to current post position in list
- Multiple level category drop-down from the WordPress dashboard
- WordPress sort search results by custom order
- How to filter wp_list_categories output with some custom post type meta query?
- How to Filter custom post type by taxonomy?
- Filter term taxonomy metabox in custom post type
- creat filter with wp_query
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- How can I made custom taxonomies relationship?
- WooCommerce sort products by the actual product width(not the shipping width)
- How to change the post type a theme shows by default?
- filter custom post in rest api with custom function
- No Permission to add new Page, Post or CPT with Admin role
- Filter hierarchical custom post type admin page by parent, and include children & grandchildren
- Sort and filter custom post type posts by custom taxonomy
- Versioned Custom Post Type (Not the same as revisions)
- Admin Column does not populate with data
- Loop filtering Custom Post Types and/or Categories
- search suggest – filter post type
- the_content filter on some post types only not working
- How to make custom taxonomy into drop down select in a custom metabox
- Create a Dropdown from Custom Post Type
- CPT Validation to not show “Post updated.”
- Custom filter function not working with Custom post type
- Edit Custom Post Type on Custom Admin Page instead Post Admin
- Filter Posts from the Main Query
- Categories filtering in new post
- How to use manage_$post_type_posts_columns with underscore in post type?
- How does the filter post_updated_messages work?
- Search filter triggered & sort by custom post type
- How to order posts of a custom post type by date DESC in dashboard Admin?
- dropdowboxes with pre-selected custom fields optios that filters the results according seach needs
- wp_dropdown_pages doesn’t work with post_type argument
- Custom post type isn’t working
- How can I add a filter to a particular post format?
- Is there any way to get list of all possible filter hooks for all post types?
- Can I display custom post types in home.php or need page template?
- Create new custom post and post category of same name
- Add a ‘guide’ image to custom post type admin page
- wordpress remove views from action links in a custom post
- wp_insert_post wrong post type [closed]
- Use remove_meta_box conditionally on custom post type
- New “Custom Types” item in admin menu. Is this a plugin or a new wordpress feature?
- How to group navigation items in the admin panel
- Filter posts by tax (dropdown) and meta value
- Sortable column containing numeric values for Custom Post Type at WordPress Backend
- Page Template Dropdown For Custom Post Types
- How to check if post/page or taxonomy post is published by admin
- Linking to Post Types from wp-admin
- Plugin or method of allowing user to rearrange custom post types with drag and drop?
- How can I remove filters from custom post types?
- CPT Columns doesn’t show categories
- Insert Custom Post Types
- I need to add a filter to prepend the term ‘National – ‘ to the post title if the post is tagged to multiple states
- echo selected value from dropdown
- Unable to display selected post title in frontend from metabox wp_dropdown_pages()
- 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?
- Problem with Apply Filters on URL in meta box filed of custom port type
- how to retain the ability to modify the post slug after applying a post_type_link filter?
- Add ‘page template’ column to dashboard for CPTs
- How do I show a link or ‘Read More’ button on a custom field excerpt when it is less than the word limit
- How to filter url on post submission?
- Filter posts of custom post type by meta key in (List All Section)
- Add search to ‘Parent’ dropdown
- Modifying WP_Title For Custom Post Type
- get_post_types not working properly in admin
- Filtering the_content, but still need to display the unfiltered content inside filter
- Set Default Option Value as Blank for Meta Box
- How to selected value default in option list?
- Display Taxonomy Term Children in a Drop Down without Submit Button
- Change Custom Post Type singular_name through function/filter
- Modify a plugin function output from another plugin
- Custom Taxonomy Filter Issues
- Catch and display error on save_post action
- Is there a hook between clicking on “Add new” and the edit screen of a new post?
- Require custom post type if is_admin() – template doesn’t show up?
- Function to add custom HTML into head in custom post-type list page
- Drop down list with posts within the “add new” page
- Multiple custom post types on same admin page
- show most viewed posts of last days by link?
- using the loop in custom meta is messing up ‘add new’ post type
- WordPress admin for a custom post, hide/collapse the main “title” and “description” boxes