I am not sure how your code looks but this is possible :
if(some condition ...){
$meta_value = "primary";
}else{
$meta_value = "secondary";
}
$the_query = new WP_Query( array( 'meta_key' => 'school', 'meta_value' => $meta_value ) );
You can change meta_value according to kind of post you want to show your users. Above will fetch posts according to primary or secondary.
And for default users you can just run query without meta_value arg as it will fetch posts based on meta_key = school irrespective of meta_value.
This is idea how you make it working.
For some details please visit this page or this and Wordpres codex page
Related Posts:
- remove custom post type permalink
- How can I remove the “Add New” button in my custom post type?
- Media library – Limit images to custom post type
- Sort search results by post type
- Custom sortable columns ordered by meta-value?
- How to change “Draft” string for status of custom post type to “Unavailable”?
- How can I filter posts by post_parent in the admin?
- Sort Order for a Custom Query in a Post Type Archive Not Working
- How do I filter the excerpt metabox description in admin?
- How do I Filter Custom Post Type by Custom Taxonomy in the newest WordPress RESTful API?
- Filter for “get_post_type_archive_link()”
- Filter by custom Field for Custom post type Admin Listing
- Most efficient way to search for values from CPT in Post content
- Remove wpautop from all posts/pages except my custom post type
- Remove date and category filters when editing custom post types
- Taxonomy terms with edit/filter link in wp-admin, in the list of custom posts
- Title_save_pre – Simple problem that u know for sure
- Multiple post types in archives (filter?)
- Image size filtering in Media uploader according to custom post type
- wp_query and comment_parent – select only posts with top level comments
- Want to filter only parent post in admin area
- Hooking into wp_export filter for custom post type [closed]
- Custom Post Row Actions
- Filters post in admin with dropdown select, custom post type
- Admin List Dynamic Heading
- How can I add a column in the wp_list_table of the admin area?
- How to filter the description of a custom post type
- Filter home_url for custom post type
- Add Content Exclusively to a Custom Post Type Feed
- register_taxonomy and register_post_type does not work [closed]
- Query Multiple Meta Values and display only when it has both meta values
- Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?
- How to query custom post types posts filtered by multiple custom taxonomies through a form selection
- Add meta value to custom post type on publish
- Filtering WP_Query
- Displaying custom taxonomy in the admin list of a custom post type
- How can I run this code once so that my generated post title doesn’t keep changing on publish/update?
- How do I create an archive page as a including metadata?
- How do I set default meta value by post type?
- How to Filter custom post type by taxonomy?
- Filter term taxonomy metabox in custom post type
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- How to change the post type a theme shows by default?
- filter custom post in rest api with custom function
- 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)
- Loop filtering Custom Post Types and/or Categories
- the_content filter on some post types only not working
- Custom filter function not working with Custom post type
- How to use manage_$post_type_posts_columns with underscore in post type?
- Search filter triggered & sort by custom post type
- How can I add a filter to a particular post format?
- wordpress remove views from action links in a custom post
- Filter posts by tax (dropdown) and meta value
- How can I remove filters from custom post types?
- sortable columns for multiple custom post types not working
- I need to add a filter to prepend the term ‘National – ‘ to the post title if the post is tagged to multiple states
- 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?
- Change Custom Post Type singular_name through function/filter
- Catch and display error on save_post action
- show most viewed posts of last days by link?
- Is possible register two archive pages for single custom post type?
- Display custom post front end filter by ACF equals current user
- conditional filter
- Custom Permalink For Custom Post Type – Working Fine But Broken For Pagination
- Best way to fix bad count on All | Mine | Published
- Query to show post current day
- Query posts by current ACF meta key value on single page as related posts
- Filter in Custom post type to find the parent post
- How can I add image sizes for a specific custom post type?
- Add content to wordpress edit.php page
- How to use multiple orderby conditions on query search results? (orderby one post type, relevance)
- add_rewrite_tag broke permalinks that doesn’t use that specific tag
- pricefilter without WooCommerce
- Insert custom taxonomy into category query
- filter rest api post by a acf filed
- Group Custom Posts Types in a Relation field of ACF
- how it’s possible to show from a post of a custom post type the taxonomy/terms?
- Add filter button to custom post type in admin area
- Grouping and paging CPT events by month with custom field date
- Highlight a Post on archive page if it has a new comment?
- Adding Information To All Posts Screen
- Filter Content on all Post Types
- Custom post type with Filter and Page Nav
- Converting a checkbox filter for custom fields to a dropdown
- Exclude Custom Post Type from shared Custom Taxonomy
- Diffrent search templates for different post types
- How to filter posts by categories?
- How do I filter a custom post type loop by a field?
- A to Z list for custom post types
- Display a list of posts whose meta field values are equal to the ID of the post being viewed?
- Check for custom field value in different post type than current one and do something
- Trying to set up a range filter for related custom post types
- Filter page ID outside the loop and order
- Paginate yearly archives for a custom post type
- Custom post type template not loading from plugin
- How can I filter records in a custom post type list in the admin based on the ACF field in the post that contains the current user?
- Modify wp_title for custom post types using custom fields data?