Title: Custom Field not showing code
Last modified: August 22, 2016

---

# Custom Field not showing code

 *  [legion_x](https://wordpress.org/support/users/legion_x/)
 * (@legion_x)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/custom-field-not-showing-code/)
 * Hello,
 * i would like to add a custom field to the general settings page of wordpress 
   for inserting google tag manager code:
 * add_filter(‘admin_init’, ‘my_general_settings_register_fields’);
 * function my_general_settings_register_fields()
    { register_setting(‘general’,‘
   google-tag-manager’, ‘esc_attr’); add_settings_field(‘google-tag-manager’, ‘<
   label for=”google-tag-manager”>’.__(‘Google Tag Manager’ , ‘google-tag-manager’).'
   </label>’ , ‘my_general_settings_fields_html’, ‘general’); }
 * function my_general_settings_fields_html()
    { $value = get_option( ‘google-tag-
   manager’, ” ); echo ‘<input type=”text” id=”google-tag-manager” name=”google-
   tag-manager” value=”‘ . $value . ‘” />’; }
 * I use
 * <?php echo get_option(‘google-tag-manager’); ?>
 * in the template for displaying. it’s working, but on instering code into the 
   textfield it returns:
 * & lt;!– Google Tag Manager –& gt;
 * so the script code isn’t shown correctly…”<” becomes “& lt;” for example.
 * Can you help me to solve this problem

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/custom-field-not-showing-code/#post-5709283)
 * WP tends to pass every text field through `htmlentities()` whether you want it
   or not. There’s probably some clever way to prevent this, but I’d take the easy
   way out and just undo the entity conversion after `get_option()` with either `
   str_replace()` or `html_entity_decode()`.

Viewing 1 replies (of 1 total)

The topic ‘Custom Field not showing code’ is closed to new replies.

## Tags

 * [custom field](https://wordpress.org/support/topic-tag/custom-field/)
 * [Scriptcode](https://wordpress.org/support/topic-tag/scriptcode/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/custom-field-not-showing-code/#post-5709283)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
