PHP errors when no Primary Category selected in WP_DEBUG===true
-
If there is no primary category selected a PHP error is thrown.
If the category does not have an index of[0]
but instead has and index of[1]
then it does not work correctly.Solution? Change from
if ( ! is_wp_error( $terms ) && ( is_array( $terms ) && $terms !== array() ) ) { $this->og_tag( 'article:section', $terms[0]->name );
To:
if ( ! is_wp_error( $terms ) && ( is_array( $terms ) && ! empty( $terms ) ) ) { $this->og_tag( 'article:section', reset($terms)->name );
- This topic was modified 6 years, 9 months ago by . Reason: To stop code from wrapping
- This topic was modified 6 years, 9 months ago by . Reason: Formatting
- This topic was modified 6 years, 9 months ago by . Reason: Formatting
The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘PHP errors when no Primary Category selected in WP_DEBUG===true’ is closed to new replies.