WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] modify page widget parameter (8 posts)

  1. ShizzlePDX503
    Member
    Posted 7 years ago #

    I want to know how to remove the sub pages of the parent page in the pages widget. I use a plugin to display subpage links on the parent page therefore don't need them to show up in the navigation part of the sidebar (navigation is the page widget).

    Here is the link to better explain I guess:

    http://www.acworthcomputers.com/test/

    Under Navigation > Members, I don't want the subpages displayed.

    I am using the Greenline 1.0 template
    http://themes.wordpress.net/columns/3-columns/1659/greenline-10/

    This is what I have in my sidebar.php which wasn't making it work either even if I removed the widget from the sidebar

    <ul id="sidebarleft">
    <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(1) ) : else : ?>
    
     <li id="categories"><?php _e('<h2>Categories</h2>'); ?>
    	<ul>
    	<?php wp_list_cats(''); ?>
    	</ul>
     </li>
    
     <li id="archives"><?php _e('<h2>Archives</h2>'); ?>
     	<ul>
    	 <?php wp_get_archives('type=monthly'); ?>
     	</ul>
     </li>
    
    <h2>Navigation</h2>
       <ul><a href="<?php bloginfo('url'); ?>/">
             <?php wp_list_pages("title_li=&depth=1&sort_column=menu_order ");?></li></a></ul>
    
    <?php endif; ?>
    		</ul>

    I know that the parameter that needs to be changed is:
    depth=1
    I just don't know if there is something in the widgets.php file that needs to be edited or something cause I have changed the
    title_li=&depth=1&sort_column=menu_order
    to
    title_li=&depth=0&sort_column=menu_order
    with no avail!

    Any Ideas?

  2. MichaelH
    Member
    Posted 7 years ago #

    If it is the category widget in 2.2, then look at wp-includes/widgets.php in the 578-640 line area.

    Lines 329-352 for the pages widget.

  3. ShizzlePDX503
    Member
    Posted 7 years ago #

    so what is it that I need to do with that code? which I will paste here:

    function wp_widget_pages($args) {
    	extract($args);
    	$options = get_option('widget_pages');
    	$title = empty($options['title']) ? __('Pages') : $options['title'];
    	echo $before_widget . $before_title . $title . $after_title . "<ul>\n";
    	wp_list_pages("title_li=");
    	echo "</ul>\n" . $after_widget;
    }
    
    function wp_widget_pages_control() {
    	$options = $newoptions = get_option('widget_pages');
    	if ( $_POST["pages-submit"] ) {
    		$newoptions['title'] = strip_tags(stripslashes($_POST["pages-title"]));
    	}
    	if ( $options != $newoptions ) {
    		$options = $newoptions;
    		update_option('widget_pages', $options);
    	}
    	$title = attribute_escape($options['title']);
    ?>
    			<p><label for="pages-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="pages-title" name="pages-title" type="text" value="<?php echo $title; ?>" /></label></p>
    			<input type="hidden" id="pages-submit" name="pages-submit" value="1" />
    <?php
    }
  4. MichaelH
    Member
    Posted 7 years ago #

    In the template tag, wp_list_pages(), use the depth=1 parameter.

  5. ShizzlePDX503
    Member
    Posted 7 years ago #

    Alright so after much fideling with the code, I removed all the widgets from the left sidebar and put in the code at the top of sidebar.php it works, however I am unable to add any widgets due to the navigation section disapears and only the widgets appear. Is there a list of the codes that I can look at to see how to add widgets to sidebar.php manually? Like how would I display the calendar using code rather then the auto widget?

    Thanks for the help MichaelH, I really appreciate it. I am learning alot through all of this. Maybe in the end I will be a widget pro... lol :)

  6. ShizzlePDX503
    Member
    Posted 7 years ago #

    Nevermind I figured out the calendar, I just used:

    <li id="calendar"><h2>Calendar</h2>
            <ul><?php get_calendar(); ?></ul></li>

    and voila presto a calendar appears, that amazing... LOL!

    Thanks again.

  7. moshu
    Member
    Posted 7 years ago #

    Yes, it works like that: either widgets or manual editing of the sidebar.php file. You cannot have both.

    And whatever is outside of the
    <?php if ( function_exists('dynamic_sidebar')...etc
    and the closing
    endif
    - will appear regardless.

  8. ShizzlePDX503
    Member
    Posted 7 years ago #

    Thanks moshu.

Topic Closed

This topic has been closed to new replies.

About this Topic