Joe Elliott
Joe Elliott

Reputation: 23

Wordpress Sidebar Not Showing

Hi creating new theme in wordpress.

Having prob with sidebar, it should display the main parent title then all the children.

<?php if ( !function_exists('register_sidebar')|| !register_sidebar() ) : ?>
    <ul id="sidebar">
        <?php
        if($post->post_parent){
            $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
            $title_heading = get_the_title($post->post_parent);
        } else {
            $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
            $title_heading = get_the_title($post->ID);
        }

        if($children) { ?>

        <li><h3><?php echo $title_heading; ?> </h3>
            <ul>
                <?php echo $children; ?>
            </ul></li>
        <?php } ?>
    </ul>
    <?php endif; // end primary widget area ?>

but its not displaying anything.

It shows the sidebar div in firebug so is displaying sidebar.

Its on localhost so cant give url.

All help appreciated

Cheers Joe

Upvotes: 0

Views: 762

Answers (1)

Greg Pettit
Greg Pettit

Reputation: 10830

I can see one of two problems:

  1. You have a sidebar registered, which means the condition is passed and it's trying to use the widgetized sidebar; you do not have widgets in your sidebar so it is not showing anything. (in other words, if you have a sidebar, the above code will never display anything anyhow).

  2. You do not have a sidebar registered, so it's passing the condition. However, the next conditions are not passed because they're not met OR because the loop hasn't triggered yet and you do not have access to those variables.

Quick and cheap way to see if conditions are met is to simply echo out some plain text or markup just inside each condition:

...
if($post->post_parent){
   echo('Parent found');
...

(for example)

Upvotes: 1

Related Questions