Title: Changing &lt;script type=&quot;text/javascript&quot; to &lt;script type=&#039;application/ld+json&#039;
Last modified: March 27, 2018

---

# Changing <script type="text/javascript" to <script type='application/ld+json'

 *  Resolved [Sarah Haruel](https://wordpress.org/support/users/sarah-haruel/)
 * (@sarah-haruel)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/changing-script-typetext-javascript-to-script-typeapplication-ldjson/)
 * Great plugin that is so close to solving a massive problem for me
 * Hopefully this is an easy question that someone may be able to answer ?
 * Using this plugin, is it possible to have the output as
 * <**script type=’application/ld+json’id**=”sns_scripts_in_head”>
 * instead of
 * <**script type=”text/javascript**” id=”sns_scripts_in_head”>

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

 *  Thread Starter [Sarah Haruel](https://wordpress.org/support/users/sarah-haruel/)
 * (@sarah-haruel)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/changing-script-typetext-javascript-to-script-typeapplication-ldjson/#post-10119289)
 * I am trying to enter son schema but the app is changing the code negatively
 * Help !
 *  Thread Starter [Sarah Haruel](https://wordpress.org/support/users/sarah-haruel/)
 * (@sarah-haruel)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/changing-script-typetext-javascript-to-script-typeapplication-ldjson/#post-10124299)
 * I think I cobbled together a crude fix.
 * Im sure this was not the correct way to do things but if the developer ever checks
   these pages then by all means if you have the time to assist / implement this
   as a proper fix so its plugin upgrade survivable ?
 * Obviously if you were able to implement it into the plugin, then would be good
   to ensure the plugin preserves any <script type=’application/ld+json’id=”sns_scripts_in_head”
   > code that has been added into a post.
 *  /**
    * Theme Action: ‘wp_footer()’ * Outputs the globally and individually set
   Scripts at the end of the Theme’s body element. */ static function scripts() {//
   Global $options = get_option( ‘SnS_options’ ); if ( ! empty( $options ) && ! 
   empty( $options[ ‘scripts’ ] ) ) { ?><script type=”application/ld+json’id” id
   =”sns_global_scripts”><?php echo $options[ ‘scripts’ ]; ?></script><?php } if(!
   empty( $options ) && ! empty( $options[ ‘coffee_compiled’ ] ) ) { ?><script type
   =”application/ld+json’id” id=”sns_global_coffee_compiled”><?php echo $options[‘
   coffee_compiled’ ]; ?></script><?php }
 *  if ( ! is_singular() ) return;
    // Individual global $post; $SnS = get_post_meta(
   $post->ID, ‘_SnS’, true ); $scripts = isset( $SnS[‘scripts’] ) ? $SnS[ ‘scripts’]:
   array(); if ( ! empty( $scripts ) && ! empty( $scripts[ ‘scripts’ ] ) ) { ?><
   script type=”application/ld+json’id” id=”sns_scripts”><?php echo $scripts[ ‘scripts’];?
   ></script><?php } }
 *  /**
    * Theme Action: ‘wp_head()’ * Outputs the globally and individually set
   Scripts in the Theme’s head element. */ static function scripts_in_head() { //
   Global $options = get_option( ‘SnS_options’ ); if ( ! empty( $options ) && ! 
   empty( $options[ ‘scripts_in_head’ ] ) ) { ?><script type=”application/ld+json’id”
   id=”sns_global_scripts_in_head”><?php echo $options[ ‘scripts_in_head’ ]; ?></
   script><?php }
 *  if ( ! is_singular() ) return;
    // Individual global $post; $SnS = get_post_meta(
   $post->ID, ‘_SnS’, true ); $scripts = isset( $SnS[‘scripts’] ) ? $SnS[ ‘scripts’]:
   array(); if ( ! empty( $scripts ) && ! empty( $scripts[ ‘scripts_in_head’ ] )){?
   ><script type=”application/ld+json’id” id=”sns_scripts_in_head”><?php echo $scripts[‘
   scripts_in_head’ ]; ?></script><?php } }
 *  Plugin Author [WraithKenny](https://wordpress.org/support/users/wraithkenny/)
 * (@wraithkenny)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/changing-script-typetext-javascript-to-script-typeapplication-ldjson/#post-10170674)
 * You don’t need to do all of that.
 * 1. just close the script tag,
    2. add your html, 3. then reopen the script tag.
 *     ```
       </script>
   
       <script type="application/ld+json">
       ...
       </script>
   
       <script>
       ```
   
 * This plugin wasn’t designed 8 years ago for that purpose, but to add simple scripts
   and simple css without having to edit the theme. If you are going through the
   hassle of editing the plugin, you should just add the JSON tag to the theme.
 *  Thread Starter [Sarah Haruel](https://wordpress.org/support/users/sarah-haruel/)
 * (@sarah-haruel)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/changing-script-typetext-javascript-to-script-typeapplication-ldjson/#post-10170949)
 * Hi WraithKenny,
 * thanks for the response.
 * your plugin is still solid @ 8 years old and with that nifty little workaround
   it is now sitting proud.
 * I was in urgent need to sort out and had to try and get a workaround and as a
   novice to scripts etc, i had to try and cobble something together.
 * I would added the JSON to the theme but I had about 40 pages for our catering
   business and needed a per – post specific script for recipe pages.
 * Your workaround is much more elegant then my own attempt and I appreciate you
   taking the time to respond to my message ;0)
    -  This reply was modified 8 years, 1 month ago by [Sarah Haruel](https://wordpress.org/support/users/sarah-haruel/).

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

The topic ‘Changing <script type="text/javascript" to <script type='application/
ld+json'’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/scripts-n-styles_46515d.svg)
 * [Scripts n Styles](https://wordpress.org/plugins/scripts-n-styles/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/scripts-n-styles/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/scripts-n-styles/)
 * [Active Topics](https://wordpress.org/support/plugin/scripts-n-styles/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/scripts-n-styles/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/scripts-n-styles/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Sarah Haruel](https://wordpress.org/support/users/sarah-haruel/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/changing-script-typetext-javascript-to-script-typeapplication-ldjson/#post-10170949)
 * Status: resolved