Здравствуйте.
Прошу помочь задать глубину списка при выводе страниц.
Вычитал, что существует "параметр depth, который определяет глубину списка при выводе".
Нашел <?php wp_list_pages(‘title_li=’); ?> в файле sidebar.php
Менял там все по-разному, но ничего не получалось.
Потом узнал, что
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Левая колонка') ) { ?>
<!--сюда можно вставить все что угодно — будет отображаться если нет активных виджетов в этой колонке-->
<?php } ?>
Т.е. знаю, что надо редактировать wp_list_pages, но не получается, т.к. его блокирует вторая строчка в sidebar.php
Я в тупике. Где и что нужно изменить, чтоб в меню сайта (Страницы) отображались только страницы первого уровня, а при переходе раскрывались подстраницы данной страницы?
Вот код sidebar.php
<ul id="sidebarright">
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else : ?>
<li>
<h2>Recent Posts</h2>
<ul>
<?php wp_get_archives('type=postbypost&limit=05'); ?>
</ul>
</li>
<li>
<h2>Pages</h2>
<ul>
<li>
<a href="<?php bloginfo('url'); ?>" class="<?php if (is_home() || is_single()) {echo ' active';} ?>" title="<?php bloginfo('name'); ?>">Home</a></li>
<?php wp_list_pages('title_li='); ?>
</ul>
</li>
<li>
<h2>Meta</h2>
<ul>
<li><?php wp_loginout(); ?></li>
<li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php _e('Syndicate this site using RSS'); ?>"><?php _e('<abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
<li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php _e('The latest comments to all posts in RSS'); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
<li><a href="http://wordpress.org/" title="<?php _e('Powered by WordPress, state-of-the-art semantic personal publishing platform.'); ?>"><abbr title="WordPress">Wordpress</abbr></a></li>
<li><a href="http://validator.w3.org/check/referer" title="<?php _e('This page validates as XHTML 1.0 Transitional'); ?>"><?php _e('Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr>'); ?></a></li>
</ul>
</li>
<?php endif; ?>
</ul>
вот index.php
<?php get_header(); ?>
<div id="container">
<div id="leftnav">
<?php get_sidebar(); ?>
</div>
<div id="rightnav">
<?php include (TEMPLATEPATH . '/sidebar2.php'); ?>
</div>
<div id="content">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<div class="date"> <?php the_time('M-jS-Y') ?> </div>
<h3 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
<div class="entry">
<?php the_content('Continue Reading »'); ?>
</div>
</div>
<p class="postmetadata">Posted in <?php the_category(', ') ?> by: <?php the_author() ?><?php edit_post_link('Edit',' ',''); ?> -- <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></p>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('« Previous Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Next Entries »') ?></div>
</div>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php include (TEMPLATEPATH . "/searchform.php"); ?>
<?php endif; ?>
</div>
<?php get_footer(); ?>
</div>
</body>
</html>
файл functions.php
<?php
if ( function_exists('register_sidebars') )
register_sidebars(3);
function wp_list_pages2($limit=NULL) {
$defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'),
'child_of' => 0, 'exclude' => '', 'title_li' =>'', 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title');
$r = array_merge((array)$defaults, (array)$r);
$output = '';
$current_page = 0;
$r['exclude'] = preg_replace('[^0-9,]', '', $r['exclude']);
$r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', explode(',', $r['exclude'])));
$pages = get_pages($r);
if ( !empty($pages) ) {
for($i=0;$i<count($pages);$i++)
{
$class1 = '';
if (get_the_title($post->post_parent) == $pages[$i]->post_title) { $class1 = 'active';}
$output .='<li><a href="'.get_page_link($pages[$i]->ID).'" class="'.$class1.'"><span>'.$pages[$i]->post_title.'</span></a></li>';
if($limit!=NULL)
{
break;
}
}
}
$output = apply_filters('wp_list_pages', $output);
echo $output;
}
?>