It happens when the foreach()
is fed with an invalid entry, because there is no term returned. To prevent this, wrap your loop inside a conditional:
// Get the terms( categories ) for the portfolio item
$terms = get_the_terms( $post_item->ID, 'portfolio_categories' );
if(is_array($terms) || is_object($terms)){
foreach( $terms as $term ) {
// some code here
}
}
Now, the loop will only run only the post has some terms.
Related Posts:
- Handling duplicates with wp_insert_term()
- Get PHP Fatal error on globalized $wpdb: Call to a member function insert() on a non-object- I have no clue. What to do?
- get_term_link() returns correct – But illogical error-messages disturb
- PHP Warning: Attempt to read property “term_id” on bool
- What might cause “junk after document element” error?
- Trying to display terms from custom taxonomy within function
- How to disable the fatal error (WSOD) protection?
- What log files does a WordPress installation write to?
- HTTPS leads to Sorry, you are not allowed to access this page
- WSOD but WP_DEBUG not giving any errors
- Showing error “Function create_function() is deprecated”
- PHP Deprecated: Non-static method should not be called statically
- error_log over 70GB. How to stop this? [closed]
- Update wordpress fail – There has been a critical error on your website
- Getting headers already sent error from plugin
- get_the_content if it contains multiple lines it results in SyntaxError
- Object of class WP_Error could not be converted to string
- How to resolve error “Cookies are blocked due to unexpected output.”?
- New WordPress Error Message – Not seen this before
- Enable errors PHP WordPress 5.2
- Getting Warnings & Notices from Fresh WordPress 3.1.2 install
- What do these “Failed to import” errors mean and how do I fix it?
- How to use add_settings_error in register_setting callback
- Application passwords not working on localhost?
- Unable to activate wordpress importer after installing it
- Ajax return code 400
- get_term_link() returns incorrect url
- Getting 403 Access Denied Error Message in new WordPress Post
- get a simple array of all of the term names that exist in all taxonomies
- update user information
- Error! 401.shtml file not found, what’s the problem?
- Error wordpress “Call to undefined function aq_resize()” [closed]
- Strange glyphs code error
- Custom slider throwing an error
- err_connection_closed after 20 minutes when loggedin in backend
- How to Fix “Are You Sure You Want to Do This”, while uploading my theme?
- 4.2.2 stuck in an db upgrade loop with “Call to undefined method wpdb::get_col_length()”
- Cannot redeclare maybe_create_table()
- Warning: An unexpected error occurred. Something may be wrong with WordPress.org
- “Cannot modify header information” means I can’t use wp_redirect
- How can I use wordpress functionality outside of WP framework
- Errors in Add Image Popup, Media Library Tab: “in_array() expects parameter 2 to be array, null given in wp-includes/query.php”
- hypanis.ru wordpress vulnerabilty [closed]
- Preg_Match(): compilation failed unknown property name
- Child Theme Fatal Error [closed]
- Hide image if taxonomy term is empty
- Jetpack could not contact wordpress [closed]
- How to end a while loop when used in a fetch assoc function [closed]
- javascript variable to wordpress php variable
- get_terms() returns Trying to get property of non-object error for custom taxonomy
- Display posts belonging to child term
- Dummy data error
- Angular not defined [closed]
- List posts by their custom taxonomy term, with a condition
- W3 Total Cache “Preview mode could not be disabled” [closed]
- PHP displaying wrong custom taxonomy images
- Failed to import “File name”: Invalid post type jetpack-portfolio
- Error call_user_func_array() After Installing Plugin
- Error 500 when installing WordPress
- Fatal error login WordPress [duplicate]
- Warning: call_user_func_array()
- “File not found.” appears often while navigating wp-admin
- WordPress files break if I edit them, but adding a closing PHP tag fixes it
- $_GET[‘title’] in WordPress
- WordPress Error blank page In section website
- Posts, pages and some images are deleted sometimes
- Call to undefined function wordpress listing_categories
- how do i fix these errors my debug log gave me?
- Fatal error: Call to undefined function wp_add_privacy_policy_content() in /wp-admin/includes/misc.php on line 1822
- Is there a way to search for a missing endif?
- style.min.css code issue
- PHP is_embed error showing up
- Unable to customize themes in wordpress after migrating to https from http
- A SINGLE Post Giving an “Under Maintenance” Message
- Weird Cron Error
- how to display child terms with parent terms in custom taxonomy?
- Headers Already Sent
- Overcome illegal characters [duplicate]
- How to find which plugin crashes
- bypassing permission error for a plugin’s page
- Website Loading Very Slow, Each Time Different File Takes Very Long To Load
- Fatal error: Allowed memory size of bytes exhausted (tried to allocate 36 bytes)
- Any idea on how to fix this error when forcing SSL on a certain page?
- Too few arguments for printf() [closed]
- syntax error unexpected ‘}’ at 364 line
- ISOTOPE – Missing/Invalid Arguement Get Terms
- warnings & errors after MAMP to live (hosteurope)
- I’m getting Call to undefined function wp_parse_list() out of the blue
- Data inserted in database, but ajax calls error function
- Parse error: syntax error, unexpected ‘}’ in C:\wamp64\www\Proiect\aplicatie\user_check.php on line 18 [closed]
- PHP warning Invalid argument supplied for foreach() on custom page template
- undefined index [closed]
- WordPress is not sending the 2nd email in the same request
- Not able to see the error [closed]
- syntax error, unexpected ‘=>’ (T_DOUBLE_ARROW) [closed]
- Error code 499 on specific cron job
- Please Help Me, How to Fix PHP Error Undefined Array Key “srcset”
- My websit dosent worke http errors 500
- WordPress taxonomy and terms question
- 403 forbidden in admin console: fix seems to be temporary and then error is back