There is no good way to do this, but it can be done in a way. When you visit /category/ it serves it as though you are visiting a page called category. You can look for this like:
global $wp_query;
if ($wp_query->query_vars['pagename'] == "category")
{
// This is base category
}
else if ($wp_query->query_vars['pagename'] == "tag")
{
// this is tag base
}
But this should never be done. It is basically a junk query; a 404, and will send a 404 response code, so you will need to look at sending another response code. For that reason (if you decide to use it) this code should go in header.php although it could go high in 404.php (before any output).
Related Posts:
- Check if current category has subcategories
- wp_nav_menu not appearing for a couple pages
- wp_update_nav_menu_item() to insert categories
- How to get the url to tag & category base set by the user?
- Why adding Categories does not auto refresh in Backend while using my custom theme?
- is_archive() content being shown instead of is_category()
- Retrieve all posts within tag OR category?
- Edit the markup of categories list
- New Theme creation
- How to get data about category in category.php
- editing fonts of category links from the_category() funtion
- How to check category of of custom post type or not
- Set a them for all subset of category
- How to call custom category field data in theme?
- Different templates for different category tags
- Why category.php throw 404 in wordpress while calling paginate_links()?
- Woo Framework: woo_cat_featured not populating
- Inside a loop, how to change CSS class based on category name?
- Question on using custom structures for categories
- Getting the category title / description returns first matching post?
- Allow user to select categories that will display in post loop
- Insert HTML content in WP Query at specific point
- How do I retrieve the category ID (ugly permalinks) in my sub-navigation menu?
- Category page returns 404 error
- Show post categories
- Add description to categories menu in admin
- filter a loop base on specific category
- Problem with multiple loops in wordpress theme
- How to add icon over specific thumb
- How to differentiate the homepage structure from the category page structure in WordPress template?
- WooCommerce shared categories
- Show the number of the post
- Products category search not working
- In if…else condition, the else statement shows even if if statement is correct
- Can’t display posts by filtering categories using isotope.js
- Media Library Categories
- How can I add HTML classes for current taxonomy/term hierarchy into my pages to simplify styles?
- Change single.php template based on parent category
- Show posts from all categories
- If it is a top level category show children otherwise show sibling categories
- Lowest catagory link
- How to get multiple loop in category.php, my scripts becomes madness
- Category base 404 – fix
- altering theme – content generated by PAGES not PORTFOLIO
- Category Archives: Show posts categorized in parent category only
- WordPress 3.5 how to determine if user is on category listing or category edit screen?
- Display only one level subcategory in wordpress
- How can i hide the authors box from a specific set of categories and post types?
- Get all first images of posts in same category
- How to display the category featured images [closed]
- How to make /category/ URL load properly instead of 404 error?
- Exclude current post from loop
- Removing Uncategorized on post save if other category present?
- WordPress Categories in data-groups
- Not showing list if there aren’t any categories to display
- How to list all categories and their IDs using SQL query?
- How to order get_categories() in the same order as the menu?
- Difference between wp_list_categories and get_categories
- Show different menu on each woocommerce category page
- How to let the user create a selection of categories via the backend
- Have posts that belong to multiple categories, exclude some categories from homepage
- Display subcategories selectbox on each category page
- add_settings_field (exclude categories->reading) wp_category_checklist
- Retrieve post tags from from main wp_query
- Listing Post Categories on Home Page
- Get posts in a subcategory of a chosen parent
- How can I only display links from a child category
- Problem with Custom Post Type Categories
- create relationship between posts from one category and posts from another category
- Exclude the category of the current post
- Output Title of Post’s Current Category
- Excluding current category from sidebar’s post widget, elementor, query-id
- OK to redirect the root WordPress category slug?
- Show subChild categories
- Return all Tags and Categories in Separate List
- Featured Category or Special Category in WordPress
- WooCommerce REST API not returning the default products category
- Include a page’s “category” in its URL
- Excluding specific category from custom theme functions
- Using the slug of a custom post category as prefix for the underlying custom post slugs
- Change background image page header overlay for each category
- List non-empty categories from a custom post type
- Creating a linkable category list with post count
- WordPress Category url redirects to subdomain
- Querying posts from two different categories while looping inside another loop
- Loop doesn’t work
- Getting Post Tags From Certain Categories
- Getting page/category content to show up in my custom page template
- Show only one of the categories of a post in the breadcrumb?
- Category and tags goes 404
- Wrong category being displayed in URL
- Check if a post is in specific category to show an icon
- How to populate a WordPress install with a lot of categories, quickly?
- Get Child category “name” of post
- How to prevent uppercasing of menu titles
- in_category in index.php
- Show custom post type on post category page doesn’t work / breaks navigation
- How to remove “Category:” title prefix in Twenty Sixteen theme?
- How to display posts from a specific tag in the current category on a single page
- How to hide specific categories in the “add post” section for specific user roles?