Page 1 of 1
Cant get sidebar to show
Posted: Sat Jan 26, 2008 9:58 am
by glennk
Hi Guys,
Im having problems getting my sidebar to show in a wordpress theme.
Firstly I must admit I dont really know any PHP other than the very simple include commands.
I am currently trying to adapt a wordpress template to look like my site so that I can utilise a product review plugin. Mostly Ive been altering css which im slow at but im getting there.
I have almost finished and the template now resembles my site. However I can only get the sidebar to appear on the main index page and not on the seperate pages created by wordpress.
Examples can be seen here with sidebar
http://www.whitbyseaanglers.co.uk/kayak ... g-reviews/
and here without sidebar
http://www.whitbyseaanglers.co.uk/kayak ... views/?p=1
Could someone offer some pointers on what I need to do - Also bear in mind I know little of php.
Thanks in advance - Glenn
Re: Cant get sidebar to show
Posted: Sat Jan 26, 2008 10:06 am
by eyespark
You probably deleted get_sidebar() function call in one of your theme files (I think it is page.php). This function call should be right before get_footer().
Re: Cant get sidebar to show
Posted: Sat Jan 26, 2008 10:12 am
by glennk
Hello and thanks for your fast response
At first glance it looks like the code is there.
This is the code for the page where no sidebar shows
Code: Select all
<?php get_header();?>
<div id="content">
<?php if ($posts) {
foreach($posts as $post)
{
start_wp();
?>
<div class="entry">
<div class="date">
<div><?php the_time('F'); ?></div>
<div><?php the_time('jS Y'); ?></div>
</div>
<div class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></div>
<p class="info">Posted under <?php the_category(' & ') ?> <?php edit_post_link(); ?></p>
<div class="entry-content">
<?php the_content('Continue Reading »'); ?>
<?php wp_link_pages(); ?>
<h3>Related News Topics</h3>
<p class="comments">
<?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
</p>
<!--
<?php trackback_rdf(); ?>
-->
</div>
<?php comments_template(); ?>
</div>
<?php
}
} // end if (posts)
else
{
echo '<p>Sorry, No Posts matched your criteria.</p>';
}
?>
<p align="center"><?php posts_nav_link(' - ','« Prev','Next »') ?></p>
</div>
[color=#FF4000]<?php get_sidebar();?>[/color]
<?php get_footer();?>
And this is the code for the index page with the sidebar
Code: Select all
<?php get_header();?>
<div id="content">
<?php if ($posts) {
foreach($posts as $post)
{
start_wp();
?>
<div class="entry">
<div class="date">
<?php the_time('F jS Y'); ?>
</div>
<div class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></div>
<p class="info">Posted under <?php the_category(' & ') ?> by <?php the_author(); ?> <?php edit_post_link(); ?></p>
<div class="entry-content">
<?php the_content('Continue Reading »'); ?>
<?php wp_link_pages(); ?>
<p class="comments">
<?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
</p>
<!--
<?php trackback_rdf(); ?>
-->
</div>
<?php comments_template(); ?>
</div>
<?php
}
} // end if (posts)
else
{
echo '<p>Sorry, No Posts matched your criteria.</p>';
}
?>
<p align="center"><?php posts_nav_link(' - ','« Prev','Next »') ?></p>
</div>
[color=#FF0000]<?php get_sidebar();?>[/color]
<?php get_footer();?>
Am I right in thinking the bits I highlighted red are the relevant code ? Is there any glaring errors Im missing
Re: Cant get sidebar to show
Posted: Sat Jan 26, 2008 10:41 am
by eyespark
Yes, you are correct, but I probably was not. Your posts are probably using single.php file. Try editing this file and include sidebar just like in other pages.
Re: Cant get sidebar to show
Posted: Sat Jan 26, 2008 10:50 am
by glennk
Sorry,
I dont really understand. I thought both pages were calling the sidebar as they both have the same code with them ?
Re: Cant get sidebar to show
Posted: Sat Jan 26, 2008 11:09 am
by eyespark
In your theme's folder there are index.php, page.php and single.php files. I speculate that your posts are using single.php file. Try editing this file. If there is get_sidebar() in all three files, the problem is something else you accidentally messed up.
Re: Cant get sidebar to show
Posted: Sat Jan 26, 2008 11:40 am
by glennk
I checked them and all 3 of those pages show this command
<?php get_sidebar();?>
something else must be blocking it.
Re: Cant get sidebar to show
Posted: Sat Jan 26, 2008 11:49 am
by eyespark
OK, show me your sidebar.php.
Re: Cant get sidebar to show
Posted: Sat Jan 26, 2008 12:14 pm
by glennk
Code: Select all
<div id="sidebar">
<ul>
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar() ) : else : ?>
<?php if(is_home()) {?>
<?php include("menu-kayak.php"); ?>
<li>
<h3>RSS Feed</h3>
<ul>
<li class="feed"><a title="RSS Feed of Posts" href="<?php bloginfo('rss2_url'); ?>">Posts RSS</a></li>
<li class="feed"><a title="RSS Feed of Comments" href="<?php bloginfo('comments_rss2_url'); ?>">Comments RSS</a></li>
</ul>
</li>
<?php }?>
<?php if(is_home()) {?>
<?php get_links_list(); ?>
<li>
<h3>Site Admin Area</h3>
<ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<li><a href="http://validator.w3.org/check/referer" title="This page validates as XHTML 1.0 Transitional">Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr></a></li>
<li><a href="http://gmpg.org/xfn/"><abbr title="XHTML Friends Network">XFN</abbr></a></li>
<li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress</a></li>
<?php wp_meta(); ?>
</ul>
</li>
<?php }?>
<?php endif; ?>
</ul>
</div>
<!-- CLOSE sidebar-->
<div class="clear"></div>
Re: Cant get sidebar to show
Posted: Sat Jan 26, 2008 12:21 pm
by eyespark
Here, put this in your sidebar.php
Code: Select all
<div id="sidebar">
<ul>
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar() ) : else : ?>
<?php include("menu-kayak.php"); ?>
<li>
<h3>RSS Feed</h3>
<ul>
<li class="feed"><a title="RSS Feed of Posts" href="<?php bloginfo('rss2_url'); ?>">Posts RSS</a></li>
<li class="feed"><a title="RSS Feed of Comments" href="<?php bloginfo('comments_rss2_url'); ?>">Comments RSS</a></li>
</ul>
</li>
<?php if(is_home()) {?>
<?php get_links_list(); ?>
<li>
<h3>Site Admin Area</h3>
<ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<li><a href="http://validator.w3.org/check/referer" title="This page validates as XHTML 1.0 Transitional">Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr></a></li>
<li><a href="http://gmpg.org/xfn/"><abbr title="XHTML Friends Network">XFN</abbr></a></li>
<li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress</a></li>
<?php wp_meta(); ?>
</ul>
</li>
<?php }?>
<?php endif; ?>
</ul>
</div>
<!-- CLOSE sidebar-->
<div class="clear"></div>
Re: Cant get sidebar to show
Posted: Sat Jan 26, 2008 1:08 pm
by glennk
Well thats allmost cracked it
http://www.whitbyseaanglers.co.uk/kayak ... rowler-13/
Sorry to have to say almost though. Its now showing a lot of hash # signs all over the place

Re: Cant get sidebar to show
Posted: Sat Jan 26, 2008 2:55 pm
by glennk
well I know Im gonn sound really dumb here. But I found out where the hash's came from. They must have got in when I coppied the code from here.
Sorted now.
Thankyou ever so much for you assistance with this. It is appreciated

Re: Cant get sidebar to show
Posted: Sun Jan 27, 2008 5:51 am
by glennk
So just trying to get a grasp of how you did that. was this the problem ?
<?php if(is_home()) {?>
I assume it was telling the code to only show the sidebar contents on the home page ?
Also would it be ok to remove this piece of code as I intend never to use the dynamic sidebar
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar() ) : else : ?>

Re: Cant get sidebar to show
Posted: Mon Jan 28, 2008 8:07 am
by eyespark
Yes, you are correct. And you should also remove endif.