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
- Is there a way to override only a portion of the function print_media_templates defined in wp-includes\media-template.php?
- Adding Filter | Page Title | Template | Why the_title affecting on menu?
- Set post featured image to author image
- Print url to default featured image
- How to Change the WordPress Locale with the ‘locale’ Filter?
- meta box loop problem with a search filter
- Is there a function to edit Blogs contents in Blogs page?
- How to filter reading/visibility posts based on role?
- How to set selected attribute on option after filter query?
- Filter on the day of the week from timestamp
- using filters on the function from class
- How to filter wp_get_recent_posts() to only posts that have thumbnails?
- How can I add a prefix to titles displayed in sidebar using function.php?
- Auto-generated excerpt with shortcode and read more button/text link
- Put data in my-account/view-order/id/ page
- How to make the show as a button?
- Change add_filter based on Ajax
- Admin view: filter posts by whether they have specific taxonomy attached
- How to remove the post pagination (Next page tag) depending on type of traffic source: from utm_campain or non-utm_campain
- Filter posts by categories ajax is showing all the posts
- ‘the_content’ Filter delivers empty string with lengh (608)
- What action/filter can be used for modifying the page to be rendered?
- Can’t set properly WordPress add_filter function
- Hook inside a hook
- Filter WordPress Archive Widget to exclude posts with specific custom taxonomy term id
- Modify Default URL for /wp-includes/js/wp-emoji.js?ver=4.6.1
- Remove the post_content search from WHERE clause (and CONCAT sql function)
- Style Radio Buttons inside Edit Page (Custom Fields)
- List all image sizes still getting disabled sizes
- mu-plugins body_class filter not working
- Add filter button to custom post type in admin area
- add_filter not working inside if function
- Why this remove empty paragraphs from the_content does not works?
- Take filter from multiple functions
- gettext filter does nothing
- URL to filter posts by post meta similar to shop/?product_cat=”painting”
- Incrementing content with extra text after save/publish
- Read More in the actual excerpt
- Testing requested query in pre_get_posts
- Code restricted to dashboard, running unexpectedly in the frontend (pre_get_post and admin-ajax.php)
- Change url to posts if they have custom tax only
- How to apply a filter to everything?
- Output dynamic_sidebar_params in wp_head
- Grouping and paging CPT events by month with custom field date
- WP Job Manager – display search results from custom search form in taxonomy-job_listing_category page
- Adding user filter – Not updating data in URL
- How to sort posts according to meta value?
- Conditionally (cpt) filter previous and next_post_link
- How to add content with a filter when there’s no content in the editor
- Hide a specific post from Archive Feed
- Filter and validate user role in registration
- Post filter Month dropdown at front-end like wordpress backend
- Password protected Page add_filter to change the text doesn’t work
- wp_editor customization
- wordpress filtering out caps in wp_title? (UpperCase is changed to Uppercase)
- What problems could happen if I replaced add_filter and add_action with the function calling
- How to check which submission button was clicked?
- shortcode function outputs multiple anchor tags
- Restrict access to custom post type and filter from every query
- Converting restricted html in comments to bbcode
- check, if any “add_action” function contains string XXXXXXXXX
- What is the proper/best way to have multiple add_filter for wp-job-manager-resume
- What scope is $blog_url = get_bloginfo() inside a function
- Why none of xmlrpc filters work
- Modify WooCommerce email shipping text value
- WP REST API v2. filters doesn’t work