get_term_children
returns an array or an object (WP_Error) and you are treating it like a string when you try to feed it to substr
. I am not sure what you are trying to do with that line of code but in general you need to check that you are dealing with an array and not an error and process accordingly.
$cat_children = get_category_children( $category->term_id, '', ', ');
if (is_wp_error($cat_children)) {
// do stuff
} elseif (is_array($cat_children)) {
// do other stuff
// I don't really know what you want to do here.
// Your code would, if I am reading right, chop two characters off of a string
// which strikes me as a odd thing to do given the data you dealing with
}
http://php.net/manual/en/function.substr.php
Related Posts:
- Why does the argument list_only do on Walker_Category_Checklist::start_el?
- Is There a Difference Between Taxonomies and Categories?
- Check if a post is in any child category of a parent category
- How to export and import taxonomies (category, tag and/or custom taxonomy) and their terms
- get_terms vs. get_categories: does it matter?
- Woocommerce get category image full size
- Order get_terms() By Custom Field
- Control term order on a per-post basis
- Fixing category count
- How can I get category ID by category name?
- get_terms name__like list categories according to letter
- Elegant way to add parent categories?
- How can I select a primary category?
- Custom Nav Walker menu – Display category count
- Programmatically create product category and add thumbnail in woocommerce
- Admin Panel – Disable Moving Selected Terms To Top of Metabox
- How to order the get_categories result
- Send an email when custom post type category is changed
- Are Categories, Tags and Custom Taxonomies any different in regards to SEO?
- How can I calculate the total number of categories at different hierarchy levels?
- Excluding posts from a category but only if they’re not in multiple categories
- Update term count using a callback function
- Get terms that are associated with products from current category
- Assign different category colours to different categories in the main menu
- WooCommerce – Display product child categories from specific parent
- Does WordPress Offer a Way to Find All of the Categories that Don’t Have Children?
- Add custom taxonomy terms to WordPress menu dynamically & append #slug to url
- Removed slug from CPT, now How/where do I hook the filter to the taxonomy term archive pages link?
- Getting the sub category
- Use get_term_children to get the sub category of a parent category for the current post
- Action hooks returning old category instead of new category
- Update wordpress post terms programatically
- Display empty taxonomy terms with get_terms()
- Get a list of Terms for a specific category
- Render Selected Categories in Admin Edit Post Screen differently
- When to use ‘get_category_by_path’ vs. ‘get_term_by’ to get category object from `get_query_var( ‘category_name’ )`?
- Show thumbnail for category?
- List Terms in Category
- How do I get a list of all categories that a given user has written blog posts for?
- Set post categories to include parents when setting child category
- How to get data about category in category.php
- Limit number of terms that a custom taxonomy can save per custom post type
- Inserting Category programmatically
- How can i insert term in a specific language of Polylang?
- Display Posts Loop for each parent and for each Child
- Create menu / submenu from category subcategory and posts
- Is There a Difference Between Taxonomies and Categories?
- Custom Walker for wp_list_categories
- Get posts from specific taxonomy term
- Get posts under a category with SQL
- Getting category URL with hyphens, not spaces
- get_terms function not returning anything
- Display custom taxonomy attached to the post on post single page
- wp_dropdown_categories not showing option as selected
- Ive got a term (get_term_by) but now I want to filter it by a category it is in?
- Hooking to walker_nav_menu_start_el to insert list of subpages
- Get a count of how many times a term or a category is used in posts
- Get Categories Where Taxonomy Equals ‘n’
- Display sibling categories on category page
- How to modify the output of wp_terms_checklist when used within the built-in category metabox on edit posts?
- Count tags for a specific category
- wp_list_categories walker without links on categories that have subcategories (to make a nested dropdown menu)
- How to Link to Most Recent Custom Post of Same Term
- set terms to category and subcategory
- Getting Category Children
- More efficient way to list posts by category [duplicate]
- Showing HTML if Post is In Certain Taxonomy Term
- How to get selected taxonomy or category ID if using custom walker?
- Exclude categories by ID
- Using in ‘category_name’ in ‘$query->set();’?
- How to store category and tags separatly on wordpress?
- Check is category parent with ids from the childs – get_term_children
- Post to inherit custom category background image from parent
- wp_delete_term or wp_delete_category?
- Update custom category fields front-end
- Combining these queries? (Same taxonomy term + same category as post)
- wp_dropdown_categories() show elements checkbox
- WP-CLI Add category as menu item main-menu
- Add properties to term object
- get_object_term_cache duplicate terms after update to wordpress 6
- Show subChild categories
- List taxonomy terms assigned to a post in hierarchical view
- Sort categories by custom field in WordPress admin
- How to get immediate children of a ‘term’ parent id through ‘get_terms’?
- Ordering terms whilst in loop
- Replace deprecated get_category_children code with get_terms
- Can’t display posts by filtering categories using isotope.js
- How to remove an item from a custom Walker_Nav_Menu
- How to remove parent category from child category url using wordpress rewrite rule?
- Get WooCommerce product category list in functions.php
- Restrict retrieved terms by category?
- List non-empty categories from a custom post type
- How to modify custom category field from front end?
- outputting taxonomy hierarchy
- Getting child category id (help with improving my code)
- Bulk Change WordPress category Slug
- How to get the term id inside the start lvl method of category walker?
- Add subcategories posts to the counts column at the admin’s categories list
- show only terms from parent category
- Categories and Tags Conflict after Woocommerce Installation