Title: PHP errors when no Primary Category selected in WP_DEBUG===true
Last modified: June 22, 2018

---

# PHP errors when no Primary Category selected in WP_DEBUG===true

 *  Resolved [Mike Schinkel](https://wordpress.org/support/users/mikeschinkel/)
 * (@mikeschinkel)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/php-errors-when-no-primary-category-selected-in-wp_debugtrue/)
 * 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 7 years, 11 months ago by [Mike Schinkel](https://wordpress.org/support/users/mikeschinkel/).
      Reason: To stop code from wrapping
    -  This topic was modified 7 years, 11 months ago by [Mike Schinkel](https://wordpress.org/support/users/mikeschinkel/).
      Reason: Formatting
    -  This topic was modified 7 years, 11 months ago by [Mike Schinkel](https://wordpress.org/support/users/mikeschinkel/).
      Reason: Formatting
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fphp-errors-when-no-primary-category-selected-in-wp_debugtrue%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Md Mazedul Islam Khan](https://wordpress.org/support/users/mazedulislamkhan/)
 * (@mazedulislamkhan)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/php-errors-when-no-primary-category-selected-in-wp_debugtrue/#post-10429085)
 * Thanks for bringing this to our attention. We’d welcome you to submit a pull 
   request in [our development repository](https://github.com/Yoast/wordpress-seo/)
   so our development team can look into this further.
 *  Thread Starter [Mike Schinkel](https://wordpress.org/support/users/mikeschinkel/)
 * (@mikeschinkel)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/php-errors-when-no-primary-category-selected-in-wp_debugtrue/#post-10429086)
 * [@mazedulislamkhan](https://wordpress.org/support/users/mazedulislamkhan/) – 
   I will do that, thanks.
 *  Thread Starter [Mike Schinkel](https://wordpress.org/support/users/mikeschinkel/)
 * (@mikeschinkel)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/php-errors-when-no-primary-category-selected-in-wp_debugtrue/#post-10429166)
 * [@mazedulislamkhan](https://wordpress.org/support/users/mazedulislamkhan/)
    Done:
   [https://github.com/Yoast/wordpress-seo/pull/10122](https://github.com/Yoast/wordpress-seo/pull/10122)

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.

 * ![](https://ps.w.org/wordpress-seo/assets/icon-256x256.gif?rev=3419908)
 * [Yoast SEO - Advanced SEO with real-time guidance and built-in AI](https://wordpress.org/plugins/wordpress-seo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-seo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-seo/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-seo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-seo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-seo/reviews/)

## Tags

 * [bugs](https://wordpress.org/support/topic-tag/bugs/)
 * [code quality](https://wordpress.org/support/topic-tag/code-quality/)
 * [wp_debug](https://wordpress.org/support/topic-tag/wp_debug/)

 * 3 replies
 * 2 participants
 * Last reply from: [Mike Schinkel](https://wordpress.org/support/users/mikeschinkel/)
 * Last activity: [7 years, 11 months ago](https://wordpress.org/support/topic/php-errors-when-no-primary-category-selected-in-wp_debugtrue/#post-10429166)
 * Status: resolved