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
- Add a category to posts, that DO NOT contain two specific keywords?
- get_the_category listing in hierarchial order
- Multiple Category Query
- Is it possible to add/tick a category to a post when it is created?
- Excluding posts not working
- How to include my own css in post
- Exclude current custom post on single post
- Hide posts belongs to few categories in homepage
- Custom post types related to same custom post type?
- why does wordpress ignore the post args?
- How do I insert a post with custom post type and relate it to a custom taxonomy?
- How to get posts and comments amount per hour, per year and per month?
- post category in wp_insert_post
- Get all custom post types excepted some…
- Limit the number of posts a category can have – newest post goes in, oldest one drops out, possible? plugin?
- “about us”, ” contact” sections should be article(post) or page in the simple small Business website?
- Page template is accessing the incorrect posts?
- Get all comments of author’s posts
- First x post with another template then the others
- Why Query is returning empty array?
- How to get subcategories from category slug?
- Remove current category from post but display all others
- How show categories in admin and get that selected to show posts in index
- Delete all drafts?
- Is it possible to customize the post according to post format in single.php?
- Customize rel=canonical tag for single blog post
- a little direction on custom post type
- disable Tab post on nav-menus page (Admin)
- Showing categories and subcategories with posts
- Change default category when I publish a post
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- Wrap every month posts in div
- store posts_id of category into a varable?
- Inner join overrides Advanced Custom Fields plugin’s get_field [closed]
- meta_value timestamp older than now
- Counter is skipping post when I still want it visible [closed]