Cant get sidebar to show

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
glennk
Forum Newbie
Posts: 8
Joined: Sat Jan 26, 2008 9:51 am

Cant get sidebar to show

Post 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
eyespark
Forum Commoner
Posts: 50
Joined: Tue Jan 24, 2006 7:36 am

Re: Cant get sidebar to show

Post 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().
glennk
Forum Newbie
Posts: 8
Joined: Sat Jan 26, 2008 9:51 am

Re: Cant get sidebar to show

Post by glennk »

Hello and thanks for your fast response :D

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 &#187;'); ?>
                    <?php wp_link_pages(); ?>               
                    <h3>Related News Topics</h3>
                    
                    
                    <p class="comments">
                        <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?>
                    </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(' - ','&#171; Prev','Next &#187;') ?></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 &#187;'); ?>
                    <?php wp_link_pages(); ?>
                                    
                    
                    
                    <p class="comments">
                        <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?>
                    </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(' - ','&#171; Prev','Next &#187;') ?></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
eyespark
Forum Commoner
Posts: 50
Joined: Tue Jan 24, 2006 7:36 am

Re: Cant get sidebar to show

Post 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.
glennk
Forum Newbie
Posts: 8
Joined: Sat Jan 26, 2008 9:51 am

Re: Cant get sidebar to show

Post by glennk »

Sorry,

I dont really understand. I thought both pages were calling the sidebar as they both have the same code with them ?
eyespark
Forum Commoner
Posts: 50
Joined: Tue Jan 24, 2006 7:36 am

Re: Cant get sidebar to show

Post 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.
glennk
Forum Newbie
Posts: 8
Joined: Sat Jan 26, 2008 9:51 am

Re: Cant get sidebar to show

Post by glennk »

I checked them and all 3 of those pages show this command

<?php get_sidebar();?>

something else must be blocking it.
eyespark
Forum Commoner
Posts: 50
Joined: Tue Jan 24, 2006 7:36 am

Re: Cant get sidebar to show

Post by eyespark »

OK, show me your sidebar.php.
glennk
Forum Newbie
Posts: 8
Joined: Sat Jan 26, 2008 9:51 am

Re: Cant get sidebar to show

Post 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>
eyespark
Forum Commoner
Posts: 50
Joined: Tue Jan 24, 2006 7:36 am

Re: Cant get sidebar to show

Post 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>
 
glennk
Forum Newbie
Posts: 8
Joined: Sat Jan 26, 2008 9:51 am

Re: Cant get sidebar to show

Post by glennk »

Well thats allmost cracked it :D

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
:lol:
glennk
Forum Newbie
Posts: 8
Joined: Sat Jan 26, 2008 9:51 am

Re: Cant get sidebar to show

Post 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 :drunk: :lol:
glennk
Forum Newbie
Posts: 8
Joined: Sat Jan 26, 2008 9:51 am

Re: Cant get sidebar to show

Post 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 : ?>


:wink: :D
eyespark
Forum Commoner
Posts: 50
Joined: Tue Jan 24, 2006 7:36 am

Re: Cant get sidebar to show

Post by eyespark »

Yes, you are correct. And you should also remove endif.
Post Reply