
-
AuthorPosts
-
February 6, 2025 at 10:32 pm #1476557
I’m surprised I couldn’t find anything else about this on the forum as it’s happening to me on all my sites that use the portfolio… and it takes down the site completely.
In /themes/enfold/config-templatebuilder/avia-shortcodes/portfolio/portfolio.php on line 1312 inside the function sort_cat_string, the WordPress function get_the_terms() is called. get_the_terms returns OBJECTS (See: https://developer.wordpress.org/reference/functions/get_the_terms/) But the code in this function assumes it’s returning arrays, leading to Fatal errors.
I’d love to see a fix to this get integrated so I can stop manually patching it! :)
February 6, 2025 at 11:23 pm #1476562I run many portfolios – and I have never seen such a fatal error on my websites. As you mentioned, there are no other messages about this on the forum.
What exactly are you changing manually? – Do you have any custom post types running?February 6, 2025 at 11:53 pm #1476565$item_categories = get_the_terms( $the_id, $params['taxonomy'] ); if( is_object( $item_categories ) || is_array( $item_categories ) ) { foreach( $item_categories as $cat ) { //fix for cyrillic, etc. characters - isotope does not support the % char $cat['slug'] = str_replace('%', '', $cat['slug'] ); $sort_classes .= $cat['slug'] . '_sort '; } }
becomes
$item_categories = get_the_terms( $the_id, $params['taxonomy'] ); if( is_object( $item_categories ) || is_array( $item_categories ) ) { foreach( $item_categories as $cat ) { //fix for cyrillic, etc. characters - isotope does not support the % char $cat->slug = str_replace('%', '', $cat->slug ); $sort_classes .= $cat->slug . '_sort '; } }
Since they are objects, not arrays. I usually have custom post types and custom taxonomies. These are going through custom taxonomies in my current example.
-
This reply was modified 1 month ago by
christiemade.
-
This reply was modified 1 month ago by
christiemade.
February 7, 2025 at 12:11 am #1476568the other way round ? the first is your edited version – and the second the existing enfold one?
February 7, 2025 at 2:16 am #1476573The second one is what I’m changing it to – but I see what you mean, a fresh copy has these changes in them! But I have clients who when they auto-update are getting the old version of this code, and the site crashes, so I guess that’s where the investigation needs to go…. Let me check and see how they’re updating.
February 7, 2025 at 2:34 am #1476574Confirmed that in this most recent case it occurred when she updated the theme automatically through the Theme Updates feature. But if it’s not in the actual Enfold files incorrectly then I’d like to keep this open and monitor it after the next update in case there is something wrong with the sync for some reason.
February 25, 2025 at 4:28 am #1477829I’ve gotten a bit turned around, I think I’ve been staring at this problem too long. It seems that Enfold uses objects by default and that’s the problem, and that’s the error I’m getting.
PHP Fatal error: Uncaught Error: Attempt to assign property “slug” on array in */public_html/wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/portfolio/portfolio.php:1312
and the manual fix I have to make is to switch them to arrays. (The opposite of what I said earlier).I guess the question is why is $cat seen as an array here?
$item_categories = get_the_terms( $the_id, $params['taxonomy'] ); if( is_object( $item_categories ) || is_array( $item_categories ) ) { foreach( $item_categories as $cat ) { $cat->slug = str_replace('%', '', $cat->slug ); } }
-
This reply was modified 2 weeks, 1 day ago by
christiemade.
-
This reply was modified 2 weeks, 1 day ago by
christiemade.
-
This reply was modified 2 weeks, 1 day ago by
christiemade.
-
This reply was modified 2 weeks, 1 day ago by
christiemade.
-
This reply was modified 2 weeks, 1 day ago by
christiemade.
-
This reply was modified 2 weeks, 1 day ago by
christiemade.
-
This reply was modified 2 weeks, 1 day ago by
christiemade.
-
This reply was modified 2 weeks, 1 day ago by
christiemade.
February 25, 2025 at 5:00 am #1477841I printed out $item_categories and it shoots back a WP_Error Object, so that’s surely the issue.
February 25, 2025 at 6:17 am #1477852Hi,
We can’t reproduce the issue on our end. The sorting categories are returned as objects, not arrays.
Have you tried deactivating the plugins?
Best regards,
IsmaelFebruary 25, 2025 at 10:27 pm #1477955Go ahead and close this, I’ll have to troubleshoot why the categories are errors, which is unrelated to the original request, anyway.
-
This reply was modified 1 month ago by
-
AuthorPosts
- The topic ‘Attempt to read property “slug” on array portfolio/portfolio.php on line 1312’ is closed to new replies.