Title: Undefined variable $href_lang
Last modified: January 19, 2018

---

# Undefined variable $href_lang

 *  Resolved [John Parker](https://wordpress.org/support/users/jpwebcast/)
 * (@jpwebcast)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/undefined-variable-href_lang/)
 * Hello, I am getting this notice in my log file and in the hreflang selection 
   box within the post:
    PHP Notice: Undefined variable: href_lang in {MY_PATH}/
   plugins/hreflang-tags-by-dcgws/includes/functions.php on line 227
 * I added $href_lang = ‘x-default’; to line 218 and that removed the error and 
   populated the languages in the dropdown. Although, i’m not sure if x-default 
   is the setting the conditional statement is supposed to be looking for, or if
   it is checking which language is selected.

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

 *  [David Davis](https://wordpress.org/support/users/dcgws/)
 * (@dcgws)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/undefined-variable-href_lang/#post-9935960)
 * Hi [@jpwebcast](https://wordpress.org/support/users/jpwebcast/)
 * Thanks for your message. Actually, since `count($keys)` has to equal 0 for this
   block to render, then there would be no selected dropdowns. So, in lines 226-
   230 you can safely change:
 * `echo '<option value="'.$lang.'"';`
    `if ($lang == $href_lang) {` `echo ' selected
   ="selected"';` `}` `echo '>'.$lang_array['english_name'].'</option>';`
 * to
 * `echo '<option value="'.$lang.'"'>'.$lang_array['english_name'].'</option>';`
 * Hope this helps
 *  [David Davis](https://wordpress.org/support/users/dcgws/)
 * (@dcgws)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/undefined-variable-href_lang/#post-9935961)
 * Hi [@jpwebcast](https://wordpress.org/support/users/jpwebcast/)
 * Thanks for your message. Actually, since `count($keys)` has to equal 0 for this
   block to render, then there would be no selected dropdowns. So, in lines 226-
   230 you can safely change:
 * `echo '<option value="'.$lang.'"';`
    `if ($lang == $href_lang) {` `echo ' selected
   ="selected"';` `}` `echo '>'.$lang_array['english_name'].'</option>';`
 * to
 * `echo '<option value="'.$lang.'"';`
    `echo '>'.$lang_array['english_name'].'</
   option>';`
 * Hope this helps
    -  This reply was modified 8 years, 3 months ago by [David Davis](https://wordpress.org/support/users/dcgws/).

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

The topic ‘Undefined variable $href_lang’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/hreflang-tags-by-dcgws_91a8a0.svg)
 * [HREFLANG Tags Lite](https://wordpress.org/plugins/hreflang-tags-by-dcgws/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/hreflang-tags-by-dcgws/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/hreflang-tags-by-dcgws/)
 * [Active Topics](https://wordpress.org/support/plugin/hreflang-tags-by-dcgws/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/hreflang-tags-by-dcgws/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/hreflang-tags-by-dcgws/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [David Davis](https://wordpress.org/support/users/dcgws/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/undefined-variable-href_lang/#post-9935961)
 * Status: resolved