I am working on my blog where I wish to have a archieve for only
specific category post.
If I understand you, you are doing this wrong. What you want to do is use pre_get_posts
to restrict your archives to the one category. Something like this:
function restrict_archives_to_cat($qry) {
if ($qry->is_main_query() && $qry->is_date()) {
$qry->set('cat',5); // the category ID you wish to use
}
}
add_action('pre_get_posts','restrict_archives_to_cat');
I don’t understand the question well enough to get the conditions right, with any confidence. You may have to alter the if
conditions to make this work correctly.
Related Posts:
- Display most recent post in category instead of archive?
- Single.php Active Category Class
- get_post_type_archive_link(‘post’) returns current category archive
- Category List (Archive) Page Template By Category
- singular posts using archive styling
- Post-Archive like a page in a specific subdirectory
- How to view all posts (on site, not admin) that are uncategorized?
- Highlighting Current Category in the Archive and Feeds page
- Posts are not displaying on their category and tag page
- show image gallery in archives or category page
- Get posts from category from custom query
- How to organise post by category and date
- How to get pagination working with “Pending” Posts
- Show all posts in category
- how to show all post with its contents
- How to display related posts from same category?
- Including categories in search results
- Count how many posts in category
- Custom Single Post By Category
- Display all posts from specific categories on a page
- Convert custom fields to post categories
- Count posts in category including child categories
- Query posts from current year
- Show Custom Taxonomy Categories, Listing of Posts, and Single Post via AJAX
- Show One Category on Post
- Do I use custom post type or something else?
- What Defines What Category A Post Picks (if in multiple)
- Limit function to specific post category
- Show all post titles
- Add Category name to Post Title (h1)
- Posts are not showing up on particular category
- How can I remove posts of a certain category from homepage after a specified time period?
- How to display related posts by subcategory and not parent category
- Category Template: Need to display different content on first page of archives
- Display post category in foreach loop with category link
- Extracting post categories
- Should I use posts or pages in this scenario?
- How to limit posts by category
- List category posts alphabetically on archive.php
- Get user categories with most posts in it
- How to list recent posts in a wp nav menu?
- Dynamic dependent Dropdown lists for categories, sub-categories and posts
- How to display two blog categories as separate sections on one page?
- why does wordpress ignore the post args?
- get posts from Custom Post Type & Category
- Does WP automatically tag posts into the archive?
- How to enable custom Shortcodes in Post Category Description? [duplicate]
- Sort by last word in title
- How to call posts under a specific category on static front page?
- Give posts a particular template based on the assigned category
- How to have more than one page for your posts if you have 8 posts but can store max 4 on a page
- How to display only one category in a custom post type?
- Get only X number of categories
- inserting a category into post
- Getting posts from some categories plus some individual posts
- Change layout of post depending on category
- latest post showing up twice on posts page
- wp_list_categories() Exclude All Categories Except One
- Different post views for different category views
- Possible?! A contextually titled back link
- Allow / show post comments in category pages
- How to select a category automatically based on a word in WordPress post title?
- Display default matabox of posts(add category) wordpress
- How display related post only in Default category on single
- How to get tags when using publish_post
- How to add class to specific navbar item when post parent category is in specific category
- How do you change the permalink for posts for a single category?
- how to create a category with wp_insert_post and post_category
- Exclude posts in a category on one page but show those posts on a different page
- How to add a block to a category page?
- Excluding category from post navigation in WordPress?
- Save All Post Permalink From A Specific Category into a .txt file
- get current index of post content in category page
- Post Category link is same with Page link
- Show custom post category for single post
- Get a list of categories that are related to posts
- Querying posts from current category, using a variable as array argument
- How do I apply a wordpress function to something with no ID inside an archive page?
- Set multi posts random categories and tags
- Precedence of page permalinks over woocommerce product category links?
- Add new post only in assigned category
- Disable archiving of old posts?
- Need help writing loop to display posts by categories in separate divs
- Add category selection to function request
- Query post category & remove any post id
- Multiple Post Repeat for Related Post Loop by Category
- Show Post number of specific Category
- Same sidebar in all posts as in the category
- How to Include a common category in a custom Category Search
- How to display only one post on first category page and rest on next pages?
- Older entries link within a category page
- Viewing category won’t show up Custom post type posts
- custom sort posts in archive/taxanomy page
- Show Title/Date/Excerpt of first post & only Title for rest in Query [duplicate]
- Listing category and its posts one by one
- Print out one of 2 post category [closed]
- How to get if category has posts?
- Show some texts in posts belonging to Specific category
- wordpress category Description not allowed tag
- Site ‘Categories’: save an admin global setting with post metadata [closed]