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
- Prevent WordPress from automatically installing a new theme each year
- Can we use one WordPress installation for multiple databases, domains and content directories
- How to Add Customizer Setting in Child Theme
- When adding a custom REST endpoint, where do you put the endpoint function, and where do you put the function registration call?
- WordPress objects class reference
- Capability to edit own posts and not others
- How do you add pages on a staging server, and then move them over to production
- Any Hook Called When Post Becomes Published?
- Automatically wrap post image in div
- Theme Twenty Fifteen: Customize Color Scheme Customizer
- How to handle security on a wordpress site? [closed]
- Error after deleting Custom Post Type with a function (no trash used)
- Which freelance sites are recommended to find WordPress developers/programmers, etc
- Is it possible to set default values for custom fields in a custom post type while my plugin is being activated?
- How to Replace Words with Hypertext Link But Ignore Previously Existed Links?
- Reinstall WordPress Without Losing Data
- Paginate Author’s Post List on Custom Author Page (ANOTHER THEORY)
- WP Northwind for Theme Development?
- Taxonomy linked to pages
- How to check if site is created by wordpress? [duplicate]
- Enabling Additional CSS / custom-css
- Custom Facebook share button with custom title,url,image in wordpress
- Sort posts by multiple meta key values
- How to Call a static page in WordPress
- Can I install/embed WordPress on a ‘single page’?
- Add google org chart to wordpress page
- I’m using add_meta_box() but want to include TinyMCE editor *and* Media Uploads for each box
- custom theme ,add media not showing images in media library
- Get Image from Media Library with the Title
- Color swatches on category page? [closed]
- WordPress admin pointers tour bug?
- Best practice – pages – ACF or inline coding
- wpdb custom tables without plugin
- Add a searchbox to the body of a page
- Best way to allow overwriting images shipped with the plugin?
- How to put a site offline, including images?
- How to add css option to Header Image customizer?
- Static Front Page settings – distinguish between Front page and Post page
- How to print Array values of custom Fields Meta?
- I am trying to make a field show and save from quickedit screen
- Customizer JS API get value of customizer field
- WordPress archive index page
- Custom Registration username_exists / email_exists
- PHP Helper Class to create shortcodes
- Hide content and functions from specific user roles
- Translating (WooCommerce) placeholder text
- Woocommerce custom archive page custom content and shortcode
- Page flickers in customization mode
- We are facing this error in header unable to understand the issue
- When is the wp-settings-[time] cookie generated?
- Get All Results From Other Users That Share The Same Custom User Meta As Current User
- Hide entry-header for a specific category
- How can I setup a development environment which auto refresh page when code have changed [closed]
- How Can I add show_post_count in get_archives_link?
- Trouble with custom login page
- I want to use a product thumbnail completely different than the product image
- How can I edit the WordPress menu link to allow fb: instead of http
- Fixed bottom menu on mobile doesn’t work on search included in Child Theme of Storefront
- Change Dashboard menu position?
- Get site ID from attachment url?
- admin aoolbar add_node() and pulling in my post slug
- Flexslider empty slide
- duplicate featured image functionality in custom meta box
- How to automatically pull an information from a form field onto an other page?
- Custom Form Input not saving to Database
- How to create 2 preview button in a post?
- Move text from the side of image to below image [closed]
- Static home page ignored
- Change the default WordPress image on the dashboard login to a custom image [duplicate]
- How do I routinely extract the thumbnail of the most recent post?
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- Showing custom field contents without listing description
- Custom terms in custom category taxonomy
- Customize TinyMCE Buttons
- Setting Custom WordPress “Posts page” AS “Front page”
- Select Menu for Custom post Type does not save
- Inserting two categories
- Instead of Custom CSS Theme CSS is loading
- Changes to code not displaying
- Permalink Listing WordPress
- Has the table name in SQL for WordPress changed from WP_posts to WPCS_post?
- Multi color post title by using custom javascript inside the gutenberg editor?
- Add custom styles to the Raft theme