Since your first get_categories
call will load all terms into memory, you can just loop over ’em and check if they have an ancestor with ID 55
, and WordPress won’t ever hit the db again:
$terms = get_terms([
'taxonomy' => 'category',
'hide_empty' => false,
]);
foreach ( $terms as $k => $term ) {
if ( in_array( 55, get_ancestors( $term->term_id, 'category', 'taxonomy' ) ) )
unset( $terms[ $k ] );
}
Related Posts:
- How to Make a Category Always Selected?
- Get Objects While Deleting term
- Insert terms for custom taxonomy on plugin activation, or each page load (init hook)
- Notice: Trying to get property ‘term_id’ of non-object
- How to Get Current Custom Post Type Associated Taxonomy Term
- How to remove plugin-specific custom taxonomy terms when plugin is uninstalled?
- wp_get_post_terms Order by not working
- Ajax is not working in a loop
- term_exists() returning NULL on term that exists
- How add default term meta to prevent an error?
- add_action priority and taxonomy used in plugin
- How to display custom taxonomy and terms using/creating plugin template
- How do I create a custom role capability?
- What is the advantage of using wp_mail?
- Plugin directory “Last Updated” not changed after initial commit?
- Calling the widget id of a mult-instance widget from inside the widget?
- What is the recommended way to create plugin administration forms?
- Do I need to call do_action in my plugin?
- Fatal error: Call to undefined function wp_mail()
- Does WordPress have an Browser Agent?
- How Do I Load My Action Earlier Enough?
- How to check WordPress website username and password is correct
- WooCommerce get Shipping Class of product from either the product id or the order after order is completed
- Dequeue script, but still use wp_localize_script to pass vars
- I can’t find where a hook is being defined in a plugin – Easy Digital Downloads
- Filter on the_content ignores shortcodes
- Custom theme sufficient or custom plugin neccessary for this feature set?
- Replacing WordPress menu functionality with a plugin
- Programmatically Selecting Theme Based on URL
- Is it possible to load plugin from console with core ?
- Plugin base URL
- Database for development
- PHP library that can merge stylesheet with inline style [closed]
- Customize multisite site creation with user data
- Adding plugin settings link upon activation
- How to create multiple Gutenberg blocks in one plugin
- How to disable reCaptcha v3 except on Contact Form 7 pages?
- How to get color name in PanelColorSettings in custom Gutenberg block?
- Fetching the value of forms in WordPress AJAX
- Cannot redeclare function error on the same line
- How to add setting section in custom post type [closed]
- Get Current Menu Location inside Nav_Walker
- Append country to ‘pretty’ url but serve same page
- Where to add hooks in a class
- Adding a brand column to WooCommerce Products
- Custom GET Parameters In Plugin’s Admin Page
- Adding option to Gallery shortcode
- WordPress Search filter to remove possible script injections
- Mixing and Matching – Custom templates in a WordPress plugin
- Incorporate small angular feature in my wordpress site
- Bootstrap doesn’t work on admin menu page-How to override wp-admin style?
- Open Graph Object Debugger & url parameters – Page Not Found result
- WordPress class, using add_action to call member function does not work
- random code at the end of file after plugin upload
- How Can I add Fields in wp-option table?
- Where do I put my add_action(… and add_filter(… and do I need to remove them?
- How to Move the Comments Bubble to the Right Side of the Toolbar
- Can’t find where to modify attrbitutes
- ajax recursive calls on wordpress returning answers outsite the function scope
- Add Password Generator on password protected page
- WordPress pages are not published due to External database connection with WPDB class
- How to optimize multiple insert into wordpress database
- How to add custom options for plugin into the add post screen – like yoast seo
- In wordpress plugin wp_signon shows error
- How to find where an object first instantiatiation
- Problem with autoloader and namespaces
- Clean way to initialize plugin in newly-added site when plugin has been network activated?
- Get coordinates of selected area to use in image maps [closed]
- How to deal with different jQuery versions?
- Can I attach a plugin via my add_filter callback contents?
- How to trigger selected option from a clic. (variation product woocommerce)
- WordPress Favicon not Working For Images/Videos/PDFs
- Is “document loaded” different on admin side than public side?
- why is apiFetch throwing Unhandled Promise Rejection: TypeError: Object is not a function
- Show username only if logged in in a else no directly name
- Conditionally check if page is using template from plugin directory
- plugin css is not being applied to the page
- How to save multiple values in custom post type from front end to back end
- Yoast and another plugin
- Headers already sent on custom plugin (Export function)
- Insert Data into Database
- Handle changed Woocommerce function
- Making Woocommerce optimized for more than 500k products
- Query only title/field/featured media of posts [closed]
- To remove rendering of menus and header, plugin or theme?
- How can I give access to my plugin sections in admin?
- Displaying External Data – Not Posts
- Making plugin output customizable
- I want to add post meta for picture thum during submit for revision
- How to synchronize an e-commerce site and a pharmacy management software?
- woocommerce features to add product along with link
- Help interpreting @wordpress/create-block-tutorial-template usage error
- Leveraging Core Functionality in Icon Upload Plugin [closed]
- What’s wrong in the WordPress Meta Box Generator code?
- add category id to option name when adding an option on edit_category
- esc_url, esc_url_raw or sanitize_url?
- React Plugin Settings Page Localization
- Is it within WordPress guidelines to update another plugin’s database fields from my own plugin? [closed]
- Block Development: hamburger module throwing error in save function
- How can I chanage the user for the composer container in wp-env?