treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Wordpress conversion problem

  • I'm trying to put a small gallery in my header but can't code it for wordpress. Here's the static site mock-up. On mouse-over, the colored jpg fades in, and when clicked it opens up in a colorbox. If I just cut and paste this into my header.php file, I get a 404. Here's the failed wp version. If it helps, here is the failed code from the wp conversion attempt:
    <?php
    /**
    * The Header for our theme.
    *
    * Displays all of the <head> section and everything up till <div id="main">
    *
    * @package WordPress
    * @subpackage Starkers
    * @since Starkers 3.0
    */
    ?><!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    <head>
    <meta charset="<?php bloginfo( 'charset' ); ?>" />
    <title><?php wp_title( '|', true, 'right' ); ?></title>
    <link rel="profile" href="http://gmpg.org/xfn/11&quot; />
    <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
    <?php wp_enqueue_script('jquery'); ?>

    <?php if ( is_singular() && get_option( 'thread_comments' ) )
    wp_enqueue_script( 'comment-reply' );
    wp_head();
    ?>
    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.colorbox-min.js"></script>


    </head>

    <body <?php body_class(); ?>>

    <div class="wrap">
    <ul id="photobar">
    <li id="club"><a href="images/club.jpg" rel="group 1" title="Some Long Forgotten Club"><img src="images/club_tmbnail.jpg" alt="club_01" width="161" height="150" /></a></li>

    <li id="bulls"><a href="images/Bulls.jpg" rel="group 1" title="The Jazz Bulls">
    <img src="images/bulls_tmbnail.jpg" alt="bulls_02" width="106" height="150" /></a></li>

    <li id="simon"><a href="images/simon.jpg" rel="group 1" title="With my Son, Simon"><img src="images/simon_tmbnail.jpg" alt="simon_03" width="113" height="150" /></a></li>

    <li id="screen"><a href="images/screen.jpg" rel="group 1" title="Jazz Festival in Austria"><img src="images/screen_tmbnail.jpg" alt="screen_04" width="176" height="150" /></a></li>

    <li id="andys"><a href="images/andys.jpg" rel="group 1" title="Andy's Jazz Club"><img src="images/andys_tmbnail.jpg" alt="andys_05" width="144" height="150" /></a></li>

    <li id="comp"><a href="images/comp.jpg" rel="group 1" title="Live Recording at the Green Mill"><img src="images/comp_tmbnail.jpg" alt="comp_06" width="230" height="150" /></a></li>


    </ul></div>

    <div id="blackbar">
    <div id="header" class="wrap">
    <h1>Eric Montzka</h1>
    </div>
    <div id="underHeader" class="wrap">



    I'm not totally new to Wp, but there's obviously a few things I don't get yet. Thanks for your help.
  • I started with a Starkers theme, btw, which might be part of my problem, I don't know.
  • It looks it is working on my end. I am using Chrome.
  • Well thanks for looking, but you probably clicked on the static site link, which does work, because the "failed wp version" is definitely messed in all browsers, I'm sure it's coded wrong. I also notice when I click an image it trys to open it in [url]/images/picturename.jpg, and the next time I click an image it opens as [url]/images/images/picturename.jpg, adding a new /images each time. Weird.
  • Some progress: I realize now I can't link images in WP with relative links, so I switched to href="<?php bloginfo( 'template_url' ); ?>/images...etc. so they're loading now...I just can't get my javascript to work, even when I try running the script in the header.php itself.
  • Hey Eric, What happens when you leave out wp_enqueue_script('jquery'); and replace that with:
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script&gt;


    I have had some issues with wp not loading jQuery 'right'. I have even seen it in the correct place in the head.. but it just didn't fly. I just load it direct from Google APIs. I get much better results this way. Dunno why that should make a difference.

    Good Luck
    swirv
  • Thanks swirv, I'm glad I'm not the only one. I was bouncing back between my own jquery and google's trying to make things work, so I'm back to using google's, but no change. I know the images are loading correctly now, so that's a start. Here's what I have so far:
    1. When I view the source, the scripts seem to be loading and in the intended order: Jquery, colorbox, wp_head, my script. (If that's wrong, let me know)
    2. I'm using the exact same scripts as the html mock-up, which DOES work.
    3. Firebug error: "$ is not a function" and pointing to my $(document).ready(function(){ statement. I think that would suggest jquery is not loading, but it is.
  • What the-- Last night I looked at the site again and two of the pages started working correctly, but not the others. Today it's all working correctly. (apologies to dclardy, you were probably right) Problem is, I HAVEN'T CHANGED ANY $%#@!ING CODE!! This is not the first time I've posted a problem that suddenly corrected itself for no reason two weeks later. I think at this point I have to blame my host right? I mean, I know it's a heavy site right now-I'm not optimizing until I get thing to work right, but I have scripts and images not loading randomly, until it's been up a week or two. Has anyone else had this experience? Anyway, I'm not posting here anymore until I've switched to a host that's worth crap. Thanks for your help.
  • Cache?
  • Emptied. Several times. Different browsers. The works.