Something like this should work but you haven’t stated where you want to display the CPT pages for games.
function display_games_archive( $query ) {
if ( !is_admin() || $query->is_main_query() && is_post_type_archive( 'portcat' ) ) {
$query->set( 'category__in', 'games' );
return;
}
}
add_action( 'pre_get_posts', 'display_games_archive', 1 );
Related Posts:
- WordPress custom Query for Posts in Category display posts multiple times
- Show a Category Specific Info Box
- Setting Custom Sort Order of Posts within a Category
- Query posts from current year
- How to change the layout and styling of posts according to their category in WordPress?
- Add default content to post (for specific category)
- Show One Category on Post
- Order post by year DESC and month ASC
- Add custom field to category of custom post type
- Do I use custom post type or something else?
- Custom Theme Want To Remove One Category From All Displays
- Display page content AFTER a loop of posts
- How to start with post number x?
- Edit custom post type admin menu link
- Deleted category by mistake, all posts now have categorized category. Can i revert that?
- Display post category in foreach loop with category link
- WordPress Custom Fields (Checkboxes with multiple values)
- Most liked page not displaying posts
- How to make number of blog posts a custom field?
- How can i limit the number of posts created per category?
- How can I setup a relationship using categories in WordPress?
- WordPress Multisite – Create Default Post and New Category On New Site Install
- Set Default Category to Username
- Redirect to another page using contact form 7? [closed]
- Display post category in foreach loop
- Dynamically switch template on click
- Can’t get full post title if there a spaces in title
- if in category but only with post meta
- How to call posts under a specific category on static front page?
- Static pages not working
- displaying the categories post
- Adjust the order for returned posts
- Custom Select Query – Selecting the Year?
- Categories Listing and Highlighting current category item
- Get current taxonomy and display query accordingly
- Can I style single post that are in multiple catergories?
- Trying to exclude custom posts based on date, while sorting by custom field
- How Can I Always Display A Particular Post First Using WP_Query?
- AJAX load more posts not using correct category and repeating the same few posts
- Custom post styling per category?
- Show custom post category for single post
- How to run select query of post with category and tags?
- Querying posts from current category, using a variable as array argument
- Add Categories To Custom Post
- Query posts from newest category
- Static text above category page
- wp query custom orderby not custom field
- Custom Select Query pagination not working properly
- Query post category & remove any post id
- Sort post by category using HTML Select tag
- Get first comment link on the post itself
- How can i retrive the movies, trailers, news in a single page using search
- Special Query: Title, Terms, Content – %LIKE%
- Older entries link within a category page
- Add default content to post (for specific category)
- Display ONLY Latest Post From Several Categories
- Display one post randomly from category on home page
- Exclude a ‘portfolio’ custom category?
- Taxonomy Category category.php not working
- Post’s arent displaying
- Only show posts belonging to multiple cateogries at same time
- Need to show birthday of custom post type(Famous people in this case) in elementor. Date of birth set in custom fields
- Sort Posts Alphabetically Based on Specific Category (Divi)
- I have a website issue I am trying to resolve
- Publish pending article from front end with a button?
- How to display related posts from parent category
- What Can I Use To Add A Custom Button Between Publish button and Move To Trash?
- How to show post(excerpt) from specific category on wp page?
- user contributed content as custom post types
- Advanced Custom Fields – Storing array value for further usage
- wp_query ‘s’ parameter does not work with custom post type
- Weird problem happening with custom taxonmy when creating/updating posts
- Multiple choice in a custom taxonomy
- How to display data in archive page?
- Duplicate posts and change category
- Category Foreach keeps looping?
- CPT archive redirects to single post
- display a random post thumbnail from a random category
- Duplicate Custom Post Type and Taxonomy Slug
- How to allow visitors to filter posts by multiple taxonomies
- Limit the number of posts a category can have – newest post goes in, oldest one drops out, possible? plugin?
- a little direction on custom post type
- Create a custom posts page
- Deleted a user with administrator rights. Now all the data/content/images are lost. how to recover them back
- Exclude some posts from displaying in wp_query based on some condition
- Loading Posts & Category with Ajax
- Trim posts from WP-Query?
- How can I add a page that shows posts from a single category?
- Remove subcategory slug from url
- Advanced Query posts
- Can I show category name in url for only one of my categories?
- Current post categories and subcatecories outside of the loop
- delete post hook not being fired when deling in wordpress dashboard admin
- WordPress Delete Users from backend doesn’t work
- Meta boxes not saving
- Display the latest post from some selected authors
- Allow users to create their own page/s
- WP_Query: Fetch posts that are in (category1 and not in category2), OR posts that are not in cagegory1
- How do I display a full post, not just an excerpt?
- Make division in post_query?