How to call Javascript as header for single.php

Discussion in 'WordPress' started by charlyms21, Jan 28, 2010.

  1. #1
    I am having to display both adsense and cpalead javascript in all posts,so while making itself calling cpalead javascript for the header,what should I do with this?

    single.php starts with

    <?php get_header(); ?>
    <?php
    global $options;
    foreach ($options as $value) {
    if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); } }
    ?>
    <div id="container">

    <div id="left-div">

    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>
     
    charlyms21, Jan 28, 2010 IP
  2. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #2
    If you want to display something on the top of all pages you have to write it in header.php of the theme directory.
     
    s_ruben, Jan 29, 2010 IP
  3. charlyms21

    charlyms21 Peon

    Messages:
    178
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What if I want to display it in only single.php ie single posts alone?
     
    charlyms21, Jan 29, 2010 IP
  4. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #4
    You mean on the header place of every single post?
     
    s_ruben, Jan 29, 2010 IP
  5. charlyms21

    charlyms21 Peon

    Messages:
    178
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You are exactly right.Header on ever single post but not on any pages or home page.
     
    charlyms21, Jan 30, 2010 IP
  6. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #6
    So write this in the header.php

    
    if(is_single()){
       /* Here write the code which you want to display */
    }
    
    Code (markup):
     
    s_ruben, Jan 30, 2010 IP