WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] New sidebar won't load (8 posts)

  1. Tracey Grady
    Member
    Posted 6 years ago #

    I have created a new sidebar but it doesn't load into my page.

    On the template page I have the code

    <?php include(TEMPLATEPATH."/sidebar2.php");?>

    I can't work out why it won't load. Please help!

  2. Scooby
    Member
    Posted 6 years ago #

    do you get an error??

  3. Tracey Grady
    Member
    Posted 6 years ago #

    No error - what happens is that the page loads, and where the sidebar SHOULD be, instead the only thing that comes up is the title of the site (and I can't work out why that is, either)

  4. Scooby
    Member
    Posted 6 years ago #

    Well shouldn't you have this to call a sidebar??

    <?php get_sidebar(); ?>

  5. Tracey Grady
    Member
    Posted 6 years ago #

    The template page which calls up the sidebar has the code I mentioned above (I didn't create the template page - it came with the theme). All I did was to change the file name from sidebar_page.php to sidebar2.php.

  6. Scooby
    Member
    Posted 6 years ago #

    Well then there is definately some code in between that is throwing you off. Simply a path..

  7. Tracey Grady
    Member
    Posted 6 years ago #

    I've now tried

    <?php get_sidebar(); ?>

    which brings up a whole screen of error messages. When I change the code to

    <?php get_sidebar('about'); ?>

    (which reflects the name of the new sidebar file, sidebar-about.php) it goes back to a blank sidebar with just the title of the website showing in it - same problem as I began with.

  8. Tracey Grady
    Member
    Posted 6 years ago #

    Ok now I've got it working. After searching through the WordPress Codex for the umpteenth time, I'm now using

    <?php include ('sidebar-about.php'); ?>

    But it looks like the problem really lay within the code in my new sidebar file. I had inserted an image using

    <img src="<?php bloginfo('template_url'); ?>/images/myimage.jpg" alt="<?php bloginfo('name'); ?>" />

    which didn't work. Interestingly, I tried to insert the image using straight html

    <img src="images/myimage.jpg" />

    which didn't work either, and neither did

    <img src="images/myimage.jpg" width="200" height="250" />

    and the way I finally got it to work was to create a new <div> and insert the image as a background image, with width, height, margin and padding attributes all included.

Topic Closed

This topic has been closed to new replies.

About this Topic