Your best bet is to use the pre_get_posts
hook to adjust the query on the admin side.
Your logic is pretty complicated so I won’t try to give you a working example but the snippet below will get you started. Basically, you want to be sure your in the admin and managing the main query.
add_action( 'pre_get_posts', 'customize_admin_query' );
function customize_admin_query( $wp_query ) {
if ( $wp_query->is_admin() && $wp_query->is_main_query() ) {
// do your customizations in here.
}
}
Related Posts:
- Filter Pages by Custom Field (ACF) in admin area
- How to filter users on admin users page by custom meta field?
- is it possible to add “extra” table nav to edit-tags.php screens?
- Advanced Custom Fields and Yoast SEO keyword analysis [closed]
- What hook do I use to edit the post statuses option in admin?
- post_mime_types Filter not Working in List Mode
- How to limit the pages displayed for choosing parent page on page attribute’s menu?
- WordPress Rest filter for custom taxonomy gets applied to the admin area
- Search with filters and title
- user_has_cap filter allows edit but will not allow save
- Changing Gutenberg / WP block editor width only on pages, not posts or other taxonomies
- Why my admin doesn’t work after adding rest_prepare_post filter?
- Add Sortable Column For All Post Types
- How to add ‘total’ value to custom column title on the posts list page
- views_edit-post filter not working (custom post type)
- Filter out comments with certain meta key/s in the admin backend
- Filter pre_get_posts does not modify Mine/All/Pending
- How to apply a filter to an ACF wysiwig editor field output?
- Prevent add_filter being applied to wp-admin pages
- How to add attributes to WordPress Admin Sub Menu List Items
- Media upload default title from file name
- Admin post list – adding an option to the date filter dropdown
- How to replace username with email address in users table
- Create new custom field that calculates age
- Echo string in admin panel footer beside version no
- Filter / add_action to upgrade.php page
- How to filter with dropdown in backend for custom data
- Having wp-admin on different domain
- WordPress: Issue with filtering users using date range
- How do I disable the warning “The backup of this post in your browser is different from the version below”?
- Save something to global var in add_filter
- ACF Load Field Groups Programmatically [closed]
- Conditionally including JS based on whether ACF field is set [closed]
- Search and Filter Using Custom Post Type, Custom Taxonomy, and Advanced Custom Fields
- How to pass/get data to/from the WooCommerce data-product_variations object?
- Translating an error message
- Display WooCommerce newest product reviews on top [closed]
- Overriding wp_get_archives() apply_filters()
- How to make post and comment count unclickable with dashboard_glance_items hook
- How can I hide all posts that don’t have a thumbnail?
- Add Dropdown menu using “add_filter => wp_nav_menu_items”
- Restrict filter to run only inside specific function
- How to add a custom filter in functions.php
- How apply_filters work in WordPress?
- What functions are included in apply_filter(‘the_content’)
- Are there Limitations on filter handles?
- Hide content editor for posts after approriate date
- Buddypress: Edit activity when new blog post [closed]
- How to make a button?
- Same Conditionals Not Working on Two Different Hooks
- Filter get_template_part() $args array
- Modify a Filters Second Parameter
- How to edit dashboard search posts button texts for my CPT?
- Insert term when page is published – avoid duplicates after edits
- Filter Media by Featured on Admin
- Capture post content before page renders
- Empty string supplied as input when parsing content
- How can I remove the kses filters when saving a specific post type ? (it breaks my JSON)
- Remove_action does not work
- Filter term taxonomy metabox in custom post type
- How can I replace content in the WP Admin area before an admin page is rendered?
- How to access plugin variables from theme templates without using globals?
- WooCommerce Custom Product Validation [closed]
- Make WP not format code, not insert line breaks in between tags
- add img class to native wordpress galleries
- Get Posts updated or published within the last x hours
- Missing Argument 2 for apply_filter
- How to get a single hook from wp_head()?
- WP filter to alter admin CSS styles?
- Add sub menu page in your plugin
- Why this filter hook is not working when passing parameters?
- Is it possible to bind a function to a filter hook via Ajax?
- Change the template when the user is not logged in using page_template filter (it does not work)
- Regarding post text filtering
- WooCommerce coupon hook argument NULL when using filter woocommerce_get_shop_coupon_data
- How can I edit comment meta value before it is saved?
- Why current_user_can(‘edit_comment’) always true?
- Redirect after post deleted
- How to stop filter from running on the index.php page?
- Filter Media by attached page or blog post in Library
- How to stop DOMDocument destroying embeds?
- How to modify image caption in posts?
- Extend Nonce Lifetime for Specific Nonce Creation
- Run `wp_insert_post_data` on all posts
- How can I pass instance via apply_filters as a parameter?
- WordPress add_filter to post_date
- create a shortcode with acf including a filter
- Pagination while keeping the filters
- ACF Taxonomy search on backend (Relationship field)
- Apply a filter str_replace on specific caracters array in the_content()
- Put data in my-account/view-order/id/ page
- The title of an attachment is not working
- using ACF datepicker to filter posts on a page
- Hide H1 Title using the_title filter
- getpost content with all formatting for admin pages
- Filter image and text from post format
- Remove pipe in views admin page filter
- How to change wp-admin and wp-login urls
- Change password reqts with NO plugin without breaking resetpass link?
- How can I conditionally add the filter option_home?