I don’t think it is possible to create a subcategory.php, but you can do the following in your category.php:
$category = get_category( get_query_var( 'cat' ) );
if( !empty( $category->parent ) ) { // the category has a parent, so it is a subcategory
// do stuff
} else {
// do else
}
Related Posts:
- Need help with friendly URL’s in WordPress
- difference between esc_attr(), strip_slashes(), strip_tags()?
- Get the sidebar ID in which the current widget was dropped
- Getting $comments outside the comment template
- media_handle_upload weird thing
- Comment filtering (search)
- Prevent WordPress from loading comments
- WP_Query with the “offset” argument
- Add filename to attachment page url
- Count widgets of a certain type
- Widget Javascript code (ajax)
- Fastest way to get the comment and ping total count for a post
- Author Tracking Code!
- Custom Database Table and foreach
- Edit a custom admin page
- Post thats in Two Categories, only want to display name for one
- Custom Slider Per Page created
- Viewing checkout page removes fees from mini cart
- How do I call in a category title on a category page in a child theme?
- Is it possible to add a ribbon in the background of h1 on every page?
- Add a date updated/date modified option using custom fields
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- custom theme ,add media not showing images in media library
- woocommerce_checkout_fields modifying existing billing_phone label created new field
- Get Image from Media Library with the Title
- Trying to build simple deposit code that hooks into woocommerce
- How to add textarea field to taxonomy (tag)?
- How to pick the default selected value in wordpress dropdown?
- Get Custom Logo Alt Text
- Resizing of a header/div in a website through css in wordpress [closed]
- Contact From 7 Custom Validation Issues
- How to add an extra button on woocommerce shop page and use it to send the product info with image in a mail? [closed]
- Gutenberg block outputting JSON in front end – is this normal?
- How to change the category url jusy show /category/%category_id% in wordpress?
- Change the Labels of Users to Customers in Admin
- how do I remove the shipping from woocommerce thankyou page and from the email
- Load MediaPlayerElement after Infinity Scroll loads more posts
- Custom post type adds time/date and author to the post?
- How would you implement a CTA infront of a videoplayer? [closed]
- Get Date of custom field and use conditional logic
- Control Content On Non-Blog Pages
- need help with a user-specific custom page template
- How can I use a Tiny MCE editor in my custom Gutenberg block?
- Always logged in even if remember me is unchecked?
- Add New User, extra fields which are required?
- Add custom profile field only for site admins?
- Adding posts to custom menu [closed]
- Woocomerce custom billing address fields display in order details [closed]
- How to add an extra variable to login and authenticate it?
- user_profile_update_errors hook not executing
- Send an email to specific adress when button is clicked?
- Bind JS event to WordPress control customizer
- Color swatches on category page? [closed]
- Steps for custom data retrieval
- changing font size and font of a custom message added after comment
- Edit sticky header html – How to locate corresponding php file
- Customizer: active_callback and sanitize_callback incompatibility?
- Include custom JS without child theme
- help to change some colors (woocomerce and store locator) [closed]
- Remove add news page and posts from menu
- Custom Status of Custom Post type need to EXCLUDE from Taxonomy pages
- Saving and Restoring a Canvas on A Individual User Basis
- Show Featured Post Only On The Homepage
- Redirect specific user role to specific site after login?
- Send multiple attachments with wp_mail in PHP
- Prepopulating a specific page template with HTML/CSS
- WordPress admin pointers tour bug?
- The function can not create a table on MariaDB server
- Child theme .css files are not overriding their parent .css files
- redirect post id to post full url
- Allow a Widget to be used one time only?
- One WordPress Installation for 2 Domains
- custom meta box for page default template
- result from custom filter admin table list backend does not work
- How can I create a second multisite network in a subdirectory?
- Silo Structure; Will links from home page to a Sub-category or Post undermine silo seo advantage? [closed]
- education system [closed]
- How to wrap the list with custom class using wp_nav_menu?
- Custom search to display results within same page
- custom url rewrite for wordpress
- Extend plugin Class through functions.php
- How can I get the custom post type assigned to a current custom taxonomy for query?
- Search widget will search everything in the site, how to limit to only search gallery name
- $wpdb->replace: WHERE?
- How can I display a PHP foreach loop’s answers by AJAX
- No shipping method has been selected [closed]
- Alphabetical Custom Menu
- How Can I Move Data From Form 1 To Form 2
- How to add a do_action on refreshing of WP customizer?
- Add Custom API Call to WP-Login.php
- wp_query get post custom taxonomy in search.php
- How can I setup up an a pre-populated pdf based on what was entered? [closed]
- Theme Customization through admin panel. (Appearance-Customize)
- Get rid of title from static front page
- How can I setup a wordpress site with multi country & multi lingual support
- Function to delete a post, it’s children and it’s grand children (half way there already)
- Customize position of social icons in upme plugin [closed]
- Make custom page look exactly as homepage
- Weird 404 URL Problem – domain name being placed at end of urls
- Integrate wordpress into index page