wordpress: Conditionally run javascript and load image for post pages

I have a javascript curl effect in place which loads an image and javascript file for the curl effect. But I want to appear in the post pages only.
So I want to do:

if this is a postpage{
   load image;
   load javascript;}

What is the way to do this in wordpress with php?

Related posts

Leave a Reply

2 comments

  1. If you want to add it only to posts pages and homepages and your plug ins are troubling you..you might want to try

    <?php if (is_single()|| is_home() || is_page()){ ?>
        load image;
        load js;
    <?php } ?>
    

    if you want it for only posts and pages, try

    <?php if (is_single()|| is_page()){ ?>
            load image;
            load js;
        <?php } ?>
    
  2. not entierly sure what your after,
    but you say you have the code ont he index.php page,
    again un-sure has to, how you have this setup,

    but if its only to be shown on a post or page or a postpage? (single post),
    would be better to move your code into the header.php file? or have it only in the single.php file which means its only loaded when viewing a single post,
    in turn it wont be shown on any other pages, except the single (full post) page..

    then using the likes

    if( is_single() ){
     //then show - run your code?
    }
    

    ?

    Marty

    Edit:

    for both posts & pages then use

    if( is_single() || is_page() ){
     //then show - run your code?
    }
    

    this will only show your code when its a single post OR within a page.