Необычные хлебные крошки

Нуждаюсь в помощи.
Есть выпадающее меню вида:
страница 1
страница 1.1
страница 1.2
страница 1.2.1
страница 1.2.2
страница 1.3
страница 2
страница 2.1
Страница 3
и т.д.
Задача вывести под этим меню:
1)если находимся на странице 1 (условие – наличие "детей"):
страница 1: Страница 1.1 > Страница 1.2 > Страница 1.3
2)если находимся на странице 1.2.1 (условие – нет "детей", но есть родитель):
страница 1.2: страница1.2.1 > страница1.2.2

Задача усложняется тем, что к примеру для страницы 1 в меню записаны "детьми" страницы 1.1 , 1.2 и 1.3, а реально в админке у нее есть еще дети 1.4 и 1.5 которые не отображаются в меню, и не должны отображаться в "хлебных крошках"

Делаю так:

<?php $parent = $post->post_parent;
    $current_page = get_the_ID();
    $parent_title = get_the_title($parent);
    $sisters = get_children( 'post_type=page&post_parent=' .$post->post_parent );        
    $children = get_children( 'post_type=page&post_parent=' .$post->ID );?>
        <ul class="submenu clearfloat">
        <?php if ($children) { ?>
            <li class="current_title"><a href="<?php the_permalink();?>"><?php the_title();?>:</a></li>
            <?php foreach ($children as $child){ ?>
                <li><a href="<?php echo $child->guid;?>"><?php echo $child->post_title;?></a></li>
            <?php }
        } elseif ($parent && !$children) { ?>
            <li class="current_title"><a href="<?php echo get_permalink($parent);?>"><?php echo $parent_title;?>:</a></li>
            <?php foreach ($sisters as $sister){?>
                <li><a href="<?php echo $sister->guid;?>"><?php echo $sister->post_title;?></a></li>
            <?php }
        } ?>
        
        </ul>

но это не решает усложненную задачу с поиском части детей, записаных в меню.
Подскажите, возможно ли вообще решение такой задачи?

Решил задачу на jquery:

Breadcrumbs = jQuery('.breadcrumbs');
Current = 'current-menu';
if (jQuery('ul').closest('.'+Current+'-item').length == 1) {
    jQuery('.'+Current+'-item').clone().addClass('first').appendTo(Breadcrumbs);
    jQuery(Breadcrumbs).find('.'+Current+'-item>ul>li').unwrap().appendTo(Breadcrumbs);
    jQuery(Breadcrumbs).find('li>ul').remove();
} else {
    jQuery('.'+Current+'-parent').clone().addClass('first').appendTo(Breadcrumbs);
    jQuery(Breadcrumbs).find('.'+Current+'-parent>ul>li').unwrap().appendTo(Breadcrumbs);
    jQuery(Breadcrumbs).find('li>ul').remove();
}

но по-моему как то смахивает на говнокод. Если тут есть знатоки jquery, подскажите можно ли этот код как то облагородить?

Anonymous
Отправить
Ответ на: