get_the_terms
return and error on failure. So before your foreach loop check for the error and only run it if there is none, using is_wp_error
.
<?php
$myterms = get_the_terms( $post->ID, 'portfolio_category' );
if( !is_wp_error( $myterms ) )
foreach( $myterms as $myterm )
echo $myterm->slug . '<br />';
?>
Related Posts:
- add_action hook for completely new post?
- How can i list current author’s categories?
- How to Make a Category Always Selected?
- anything like add_meta_box for categories?
- Calling clean_term_cache() fails when called in the same plugin that creates terms, succeeds when called separately?
- Missing “category_children” option when dynamically creating categories via a plugin
- Can we create a category list page in WordPress?
- prevent post to have multiple categories in my plugin
- Show add_meta_box by selecting a specific category
- Which are the hooks run before/after when a category’s deletion?
- how do you prevent showing a particular category on the admin dashboard for specific user roles?
- Is it possible to change a term slug before being saved to the database?
- wp_insert_category() setting the ‘cat_ID’ gives not array error
- Send push when new post is published in a certain category
- How do I get the sub categories of the parent when in a sub category?
- Filter Categories widget to allow custom sorting?
- Function/Class to list categories with checkboxes
- How can I show posts for a single category?
- How to display the categories on page using shortcode?
- How to display the category id along with category name on categories list?
- add_action pre_term_description vs. pre_category_description
- How to show parents of current page category, excluding the category?
- WP Dropdown Categories, display subcategories but not grandchildren categories?
- Load stylesheet in edit category page?
- How to relate the Category to user?
- How to exclude categories from get_categories() select list inside a widget admin panel
- How to Show Category List With Corresponding Links?
- Exclude Woocommerce Product Category From Sitemap
- How to show only the last two categories in a menu?
- Determine if term is Category or Tag
- How to check category name available or not
- delete category on plugin deactivation wordpress
- Post is uncatagorized in publish_post action
- Hide post by ‘post_category’
- Woocommerce product not appearing in category list page when created programatically [closed]
- Yoast and another plugin
- Making Woocommerce optimized for more than 500k products
- Add a new tag based on the category name in the publish event
- Creating an archive page listing external data
- How can i call from custom fields to the category editor?
- What method would I use to show an image in between X amount of posts on category archive? [duplicate]
- filter on get_posts efficiently
- How to get recent one post from each category on home page?
- Add self-closing shortcode button to TinyMCE in WP 4.6
- WordPress Hook for user register
- Upload file to remote storage
- How do I conditionally enqueue script for CPT single post type with plugin?
- Is it possible to remove next-post / previous-post with out creating a custom template?
- wp_localize_script $handle
- Escaping built-in WP function return strings
- Help adding image upload functionality to widget
- How to override a function call in functions.php?
- Front-End Interfaces Without Shortcodes
- Execute plugin for specific user role(s) only
- How can I render shortcode so that its not cached by Caching plugins?
- Does WordPress support WebP images?
- Enqueue scripts in footer
- Is It Always a Best Practice to Decouple the Frontend from the Admin Area When Developing a WordPress Application?
- the_editor() function
- Including the necessary functions for a custom ajax registration form
- Why doesn’t my simple the_title filter get applied?
- WordPress clean internationalization for menus?
- Dashboard – get status and position of metaboxes and pass them to ajax method
- JSX in WordPress Plugin Development
- W3 Total Cache JS and css Minify folder are empty
- Including comments meta box on a plugin page
- How to create custom settings page for custom plugin
- Internationalizing Plugin
- Update File Once Every 30 Days
- Taxonomies within plugin invalid
- Make Database query only when option is updated
- Google credentials and redirect URI for Google OAuth2 in a WordPress plugin, questions
- How to add plugin options in wp editor page
- Service Worker Uncaught (in promise) DOMException
- Problem with display data from get_option
- WordPress Plugin Boilerplate: Addition of 3rd party scripts and styles [closed]
- How to format custom fields when editing an attachment?
- Screenshots on plugin page taken old [closed]
- How do I duplicate a single post, with all its properties, and save it as a different post?
- Extract Information from post content (using regex?)
- Using jQuery prepend() with file include
- want to show CMB2 metabox on woocommerce product data tab
- Customise Grouped Product display in Woocommerce with custom column
- Ajax action has 200 status but response of No response data available for this request
- Google Web Core Vitals – management, how to in wordpress and advice
- Hiding the WordPress login and password fields from login page
- Adding customs fields on each product on the cart
- WordPress how do I echo SUM from a column of a MySQL table by user id AND type_operation
- Buddypress: adding a new tab direct user to their author page
- Why would one specify multiple arguments when using get_previous_posts_link() which takes only one parameter?
- I have a plugin where in I have to change the title of the page dynamically by sending parameter to the_title filter
- How can I map a specific URL pattern to a plugin for processing
- Issue on Getting Images URL of the Post Gallery
- Change the class of wordpress menu
- WordPress.org how to force expire Cached Banner-772×250 from my Plugin page
- What is the Timeline for the Active Version Pie Chart in the Repository?
- How to change url’s in WordPress when changing domain [duplicate]
- Email verification feature in wordpress social login plugin
- Is wordpress plugin development active? [closed]
- I want to redirect user to an amazon product page from my wordpress website when they add product to there cart [closed]