Evan
Evan

Reputation: 1713

How to change sidebar in wordpress generated php?

How to selectively display pages on sidebar? I have some pages that i want to display and some pages that i do not want. Specifically, i have some pages that just inform the user after a successfull registration which i do not want to be displaied on sidebar. I used wordpress to generate the php with this code

    <div id="primary" class="widget-area">
        <?php get_search_form(); ?>
        <ul class="xoxo">
            <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
                <li id="pages" class="widget-container">
                    <h3 class="widget-title"><?php _e('Site Map'); ?></h3>
                    <ul>
                        <?php 
                        //code that works as it is
                        wp_list_pages( 'sort_column=menu_order&title_li=&deprth=1');

                        //code that i produced and not works as excepected
                         $top_pages_to_exclude = '2, 94, 100, 123, 125, 127';
                            $args = array
                                    (
                                        'sort_column' => 'menu_order',
                                        'title_li' => '',
                                        'deprth' => 1,
                                        'exclude_tree' => $top_pages_to_exclude
                                    );
                        wp_list_pages( $args);
                        ///////////////////////////////////////////////////////////
                        ?>

                    </ul>
                </li>
                <li id = "register" class = "widget-container">
                    <h3 class = "widget-title"> <?php _e('Register / Log in '); ?></h3>
                        <form name="login" action="" method="get">  
                            To <a href="http://localhost/bill/?page_id=74">Register</a>
                            <br/>
                            <hr/>
                            Username &nbsp <input type="text" name="user" width="200" height="20" />
                            <br/>
                            <br/>
                            Password &nbsp <input type="password" name="pwd" width="200" height="20" />
                            <br/>
                            <br/>
                            <input type="submit" value="Log In" />
                        </form>
                </li>
<!--            <li id="comments" class="widget-container">
                    <h3 class="widget-title"><?php _e('Recent Comments'); ?></h3>
                    <?php $comments = get_comments('number=5&status=approve'); ?>
                    <ul>
                        <?php foreach ($comments as $comment) : ?>
                            <?php $the_post = get_post($comment->comment_post_ID); ?>
                            <li>
                                <?php echo $comment->comment_author; ?> on <a href="<?php echo get_comment_link($comment); ?>"><?php echo $the_post->post_title; ?></a>
                            </li>
                        <?php endforeach; ?>
                    </ul>
                </li>
                <li id="categories" class="widget-container">
                    <h3 class="widget-title"><?php _e('Categories'); ?></h3>
                    <ul>
                        <?php wp_list_categories('title_li='); ?>
                    </ul>
                </li>
                <li id="links" class="widget-container">
                    <h3 class="widget-title"><?php _e('Links'); ?></h3>
                    <ul>
                        <?php wp_list_bookmarks('title_li=&categorize=0'); ?>
                    </ul>
                </li>
                <li id="archives" class="widget-container">
                    <h3 class="widget-title"><?php _e('Archives'); ?></h3>
                    <ul>
                        <?php wp_get_archives('type=monthly'); ?>
                    </ul>
                </li>
                <li id="meta" class="widget-container">
                    <h3 class="widget-title"><?php _e('Register'); ?></h3>
                    <ul>
                        <?php wp_register(); ?>
                        <li><?php wp_loginout(); ?></li>
                        <?php wp_meta(); ?>
                    </ul>
                </li>
                <li id="rss" class="widget-container">
                    <a href="<?php bloginfo('rss2_url'); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rss-icon.png" width="18px" height="18px" /></a> <span class="rss">Subscribe via <a href="<?php bloginfo('rss2_url'); ?>">RSS</a></span>
                </li>
-->
            <?php endif; ?>
        </ul>
    </div>     

Upvotes: 0

Views: 727

Answers (1)

cwhelms
cwhelms

Reputation: 1771

    <?php 
    $args = array(
'depth'        => 1,
'exclude'      => '2, 94, 100, 123, 125, 127',
'title_li'     => '',
'sort_column'  => 'menu_order',
); 

    wp_list_pages( $args );
    ?>

http://codex.wordpress.org/Function_Reference/wp_list_pages has all the options for the function

Upvotes: 1

Related Questions