Code in <head> section of wordpress

10 replies
  • WEB DESIGN
  • |
is there a way of entering code into the <head> in wordpress without causing the body to be spaced down the page?

i'm attempting to enter a code but everytime i do, it shifts the body text down about 2 or 3 spaces. how can i solve this issue?
#&lthead&gt #<head> #code #section #wordpress
  • Profile picture of the author ExploringInfinity
    are you placing your code using appearances->theme->editor and then going to the header.php file and placing your code in there?

    If so, its possible the code you are adding has some sort of spaces inserted into it.

    Have you tried placing it at the bottom of the <head> section just before </head> ??
    Signature
    Get ALL the SEO software YOU CANT afford:
    Ultimate SEO Pack
    SENuke & Grscraper, and dozens more! $40 a month!
    {{ DiscussionBoard.errors[4482654].message }}
  • Profile picture of the author mywebwork
    You must be doing it incorrectly - code in the <head> section of an HTML document (WordPress or anything that generates HTML) is not displayed and thus will not affect anything in the <body> section.

    Do a "View Source" on your outputted page and you should spot the error.

    Bill
    {{ DiscussionBoard.errors[4482659].message }}
  • Profile picture of the author redstanford
    I actually am trying to enter the code on a specific page in wordpress. Is there a way for me to put the code for just one page in the head section and how do I find the head section for each page?
    {{ DiscussionBoard.errors[4482724].message }}
    • Profile picture of the author Michael D Forbes
      The header shows up for every page. Edit it for one, you've done it for all. I'm pretty sure anyway.
      {{ DiscussionBoard.errors[4482755].message }}
      • Profile picture of the author redstanford
        Originally Posted by Micheal D Forbes View Post

        The header shows up for every page. Edit it for one, you've done it for all. I'm pretty sure anyway.
        I only want to do it for one page though, is that possible? I don't want the code on any other pages of my website.
        {{ DiscussionBoard.errors[4482791].message }}
        • Profile picture of the author Trisha
          Originally Posted by redstanford View Post

          I only want to do it for one page though, is that possible? I don't want the code on any other pages of my website.
          It is possible to show code on only one page, but it will take some php. You'll need to edit the theme files to add the following code, most likely to page.php - before the loop, depending on what you're trying to do.

          Its called a 'conditional tag' and basically tells wordpress that, if this is the right page, then add this code... if not, do nothing.
          Code:
          <?php if ( is_page('PAGE NAME OR ID') ) { ?>
          YOUR CODE HERE
          <?php } else { 
          // DO NOTHING
          } ?>
          if thats too confusing, pm me, i can take a look for you.
          {{ DiscussionBoard.errors[4482966].message }}
          • Profile picture of the author redstanford
            i should've mentioned this earlier at the start of the thread but what i'm trying to emplace is a tracking code for visual website optimizer, which is a paid version of google website optimizer - also of which i was having similar issues with the code shifting the body downward.
            {{ DiscussionBoard.errors[4483094].message }}
          • Profile picture of the author redstanford
            Originally Posted by Trisha View Post

            It is possible to show code on only one page, but it will take some php. You'll need to edit the theme files to add the following code, most likely to page.php - before the loop, depending on what you're trying to do.

            Its called a 'conditional tag' and basically tells wordpress that, if this is the right page, then add this code... if not, do nothing.
            Code:
            <?php if ( is_page('PAGE NAME OR ID') ) { ?>
            YOUR CODE HERE
            <?php } else { 
            // DO NOTHING
            } ?>
            if thats too confusing, pm me, i can take a look for you.
            That seems like it will work. One more question. how do I know what the page name or ID is? Would that be the URL?
            {{ DiscussionBoard.errors[4483113].message }}
  • Profile picture of the author redstanford
    bump for anyone else who can help out
    {{ DiscussionBoard.errors[4485685].message }}
    • Profile picture of the author internetgenius
      You can find the page ID of a WordPress page by looking at the address bar of your browser while editing the page in the WordPress dashboard ... it should look something like .../wp-admin/post.php?post=233&action=edit ...

      The page ID is the number right after post=

      Another way to easily identify page ID's is to install the pageMash WordPress plugin (do a google search for "pagemash plugin").

      Once you activate the pagemash plugin, the settings page for that plugin identifies all of your page ID's. (There are also other WordPress plugins that you can install to reveal page ID's, but pagemash has other useful features as well, like making it easy to re-order your pages and "hide" certain pages from being visible.)
      {{ DiscussionBoard.errors[4485897].message }}

Trending Topics