Reading this solution here:
has_category() for parent category
I tried a similar approach and instead of hammering down all the terms I utilized the above solution to leverage the category term or any of its sub-categories:
add_filter('the_content', 'ssws_add_content');
function ssws_add_content($content) {
$cat_id = get_cat_ID('accommodations');
$children = get_term_children($cat_id, 'category');
$ssws_custom_text="<h1>Accomodation</h1>";
if (is_single() && (has_category($cat_id) || has_category($children))) {
$content .= $ssws_custom_text;
}
return $content;
}
Related Posts:
- A way to automatically install pages on theme install?
- Why doesn’t default WordPress page view use force_balance_tags?
- Proper, exhaustive documentation for wp.editor etc
- Create “File-less” Page Template in Functions.php
- How to determine if custom menu is active?
- Including CSS and JS on Admin Screen of Custom Theme Options
- How to remove duplicate link from add_menu_page
- Custom Comments – Parent / Nested Reply
- Automatic Updates For Private And Commercial Themes?
- add_image_size is scaling, even though crop is set to true
- Adding inline styles from a widget
- Get password when user registers and save it sha1 into database
- Details of wp_localize_script
- the_content() in single-{post-type}.php problem
- How to set page template on front using starter content?
- Different Admin Theme – Based on Role?
- Finding Page Template and Displaying Content
- how to set more than one menus to the same theme location
- Override Constants in Child theme
- How do I update WooCommerce template files in my theme? [closed]
- Theme unit test data Foreign fonts come in garbled on my machine
- Removing feeds from header using a function?
- How to link to theme options page from anywhere in admin?
- trying to use wp_handle_upload with ajax
- What is the best way mark entries as featured?
- How to reorganize the items returned by wp_list_comments()?
- Add new panel inside parent panel in WP Customize?
- How do you apply multiple skins to a site via the “templates” selector using stylesheet switching?
- Add theme support for post thumbnail isn’t working from theme class
- How to make wordpress theme iframe responsive
- How to add an option for “nofollow” to the Link editor’s existing “Link Relationship(XFN) options list?
- How can I alter the display of category listings via sidebar.php?
- Need advice > converting category assignments to custom post meta values
- How to edit theme functions file to modify pagination?
- Divi – How can we show background video on mobile
- Calling post_exists() causes white screen in after_setup_theme
- What’s the best practice way of handling custom fields in different post formats?
- Dropdown filter by custom field
- Reactor Theme: Prevent Post Thumb on Post
- Efficiency of wp_options vs a new table
- How to properly create a child theme
- How can I tell what category I’m in?
- Syntax error potentially causing CSS catastrophic failure
- How to correctly enqueue the parent and child theme stylesheets in the creation of a child theme? [duplicate]
- header_image not returning header image url
- Taxonomy-$taxonomy-$term not working
- How To Pick Custom Size Of Uploaded Image In Theme Via the_post_thumbnail();?
- CSS class on last post in loop ( custom query )
- add_theme_support( ‘admin-bar’ ) causes fatal error
- how to make wordpress change the title and keep page name?
- Place title (in correct place) above image with opaque background [closed]
- Fastest way to update a theme
- Load different single.php templates according to post layout selection
- Full width featured thumbnail
- // File Security Check from WooCommerce [duplicate]
- my single.php is mixup on some post for no reason
- How do I implement jPanelMenu?
- When trying to set title, not sure how to edit it for different pages
- Site returns a 500 Internal server error
- Stylesheet is not loading on firefox and IE!
- static front page ONLY for certain themes?
- How to add cropped custom header image?
- add_action for admin_init hook with a parameter
- Changing background color depending on parent page?
- custom post type query causing errors
- Any way to change/add to the theme name dynamically?
- Is it possible for the enqueue styles function to mess up my CSS?
- how can i remove js file from my footer in wordpress
- WordPress Admin bar missing from custom theme
- WordPress theme files Organization
- Put CSS Content inside tag for WordPress
- How to display latest posts with authors image
- Menu names not getting translated
- How can I convert a list of title-posts into a sequence of comma separated text? [closed]
- Is it possible to issue a theme update that requires a new plugin?
- Get property of non-object on theme activation
- change wordpress website logo url [duplicate]
- wp_editor some functionality not working on custom theme
- Update modified Shopify third-party theme [closed]
- Malformed RSS feed
- How to add custom field option with menu?
- save prevision data in the database on theme activation
- What causes a theme to be inefficient?
- How to defeat “Blog pages show at most __ posts” setting in the loop?
- pagination/prev and next page links not showing
- Admin bar is showing up to non logged in users
- WordPress jQuery is not defined error
- on click load images on the same page [closed]
- Best practice to create required pages
- Custom background not showing
- Is there a way to prevent wp_head from outputting self-closing tags?
- Multiple content areas with Gutenberg – Transparent areas mid content
- Is it possible to have two templates in an article hirearchy?
- Website Developer has gone missing! How to gain full access of your code from a WordPress website?
- How to fix wp-env: “error: Your local changes to the following files would be overwritten by checkout”
- Do core themes normally allow automatic upgrades?
- sanitize_option_{$option} filter returns null
- WP Customizer get control value on change
- Execute javscript when theme customizer loads (autosave issue)
- How to set the margin on an innerBlock in a block variation?