Sub-categories use the regular category archive page by default. There is no function such as is_subcategory. But you can write your own.
Here is an example:
This will check if the current page is a sub-category. Or if you pass an ID it will check if the ID is a subcategory.
function is_subcategory( $cat_id = NULL ) {
if ( !$cat_id )
$cat_id = get_query_var( 'cat' );
if ( $cat_id ) {
$cat = get_category( $cat_id );
if ( $cat->category_parent > 0 )
return true;
}
return false;
}
Related Posts:
- deregister scripts on certain page
- is_front_page not working in functions.php
- disable comments if array exists
- Problem using is_single() to enqueue script from functions.php
- Conditional tag is_page with a custom post type
- Limit posts only on home page – ideally in functions.php
- Enqueue scripts not working with if is page conditional tag in functions.php
- Conditional read more adjustment
- How add various functions within 1 conditional?
- Conditional Gravity Forms filter in WordPress Multisite
- Has is_archived() for sites in a multisite changed with WP 4.7?
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- is_page() or is_single not working
- functions.php and conditional tags
- issue with if/elseif in_array inside foreach loop display only one post
- Set “woocommerce_is_purchasable” to false for specific “$product->is_stock_status”
- Entirely Different Functions.php per Page?
- Function to echo (or display?) wordpress tags in the head section
- is_home() not working in functions.php file
- If is_single in functions.php
- Enqueue script if not page template
- is_product_category(‘Services’) not working
- method to fetch entire tag list on archive.php
- Adding an IF ELSE to a function
- how to display featured image for single post for a specific category
- Load CSS conditional on custom field is present
- admin-ajax.php nulls all php variables
- restrict access to specific urls on a specific period of time
- Change conditional tag in wordpress without editing the core files
- wp_enqueue_scripts called twice?
- How can i hide content if not friend in Buddypress? [closed]
- PHP Notice: Function is_page was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false
- get php variable from functions php and echo it in theme template files [closed]
- How to influence the information displayed on widget inside wp-admin
- Remove Container Element From wp_nav_menu() Markup
- Remove Page Title from Static Frontpage
- Default or Preset Content for Custom Post Types
- If function exists, and array is met, echo function?
- Breadcrumb how i can display page title with parent > child title with permalink ? any Idea
- change a post status when users update posts?
- Display height and width properties with the_post_thumbnail() or related function
- Display a text message if the shortcode is found?
- How to use IF Statement in WordPress?
- Woocommerce Storefront WordPress Ignore Media Gallery Images and use External 3rd Party Host
- Ninja form Redirect depending on text field content [closed]
- Display Password Protected external RSS in wordpress template
- Custom HTML in specific category single page and its descendant categories
- Modify a function without editing template
- Filter out other users comments. Visualize only own comments and editor role users’ comments
- How to properly remove style for non logged in and front page only
- WordPress converts media extention URL automatically to video player
- How do you Permanently Delete Sidebars
- Add a unique class to HTML tag/element
- help I changed one currency in woocommerce and everything is ruined [closed]
- How to run a function in every page, every device
- Which function required?
- How to retrieve the values of a sub-field in the first and last row of an (ACF) repeater inside function?
- Custom Query Not Paginating
- Solved: redirect to another page using functions.php
- Getting the teaser text without overriding global variables
- Problem enqueuing scripts on not single posts
- referencing the current user in a page i created in wordpress
- is_main_query() always returning false
- Counting posts and trigger it [closed]
- ACF Flexible in TCPDF
- modifying every other element’s class inside while loop
- Adding Custom Body Class for Page: Shop
- Is it possible to use ‘wp_insert_post’ function within a for loop?
- save_post function keeps triggering: Warning: array_map(): Argument #2 should be an array… when restoring from trash
- More than one search results page template for two searches on site
- How do i create a search option for pdf’s only
- Restoring pages in wordpress
- Redirect after login to current URL
- Restrict certain roles registrations by domain
- Replacing term/taxonomy archive pages with search queries
- Return ACF Field value function
- Function to draw random image from specified category destroys site logic – why?
- Issues with add_query_arg() not passing a variable
- Add Function For Instances of Custom Text in Multiple Category IDs to display in post content
- Move captions under gallery images in twenty fourteen theme
- Force changing the Site Title and add link
- create submenu page – error function not found or invalid function name
- Undefined offset: 2
- Sorting date results from a query
- Using is_plugin_active within functions.php
- Button generate a random URL [closed]
- How do I add functionality to images?
- Why don’t ‘wp_nav_menu’ CSS classes work until a menu is created?
- multible shortcodes (for differnt values) with one function
- Problem with lists and “allowed_block_types” in functions.php (since WP 6.1.1)
- HELP: Code To Check Status And Write Debug Entry
- How to enqueue Bootstrap 4.6 js & css from local files
- Template Redirect Function Only Working When Logged In
- Auto updating JavaScript dependancy in functions.php
- Swap WordPress “Widget Area” based on Page Template
- Wanted to get rid of Paragrapgh tag in submit buttom of the WordPress form
- Create section wit form
- wp_script_add_data not working
- CF7 Remove Comma from ‘select’ ‘radio’ and ‘checkbox’ outouts
- Timeline from diferent wordpress api urls endpoint works, but diferent date