Answer the question
In order to leave comments, you need to log in
How to display the pages of the last level of nesting in WordPress?
Suppose there is such a hierarchy of nested pages:
Каталог
- Оборудование
-- Трансформаторы
--- Масляные трансформаторы
---- Масляный трансформатор 1
---- Масляный трансформатор 2
--- Сухие трансформаторы
---- Сухой трансформатор 1
---- Сухой трансформатор 2
Answer the question
In order to leave comments, you need to log in
get_pages does the same thing as wp_list_pages only prints all the data about the page
Definitely write your Walker.
https://github.com/twittem/wp-bootstrap-navwalker/...
Here for bootstrap, insert where you need the condition to display only for the current page.
Most likely you have a Catalog, Equipment, Transformers, Oil transformers, these are not pages but headings. A Oil transformer 1 etc. These are headings. If entries are located only in final headings, then there is a simple construction.
// узнаем id данной рубрики
$id = get_category(get_query_var('cat'))->cat_ID;
// смотрим все посты рубрики
$posts_array = get_posts( array('category'=>$id) );
function myPagesparent($mypageID,$MyID){
$myargs = array(
'numberposts' => -1,
'post_parent' => $mypageID,
);
$pages = get_children($myargs);
foreach ($pages as $pagg) {
if($pagg->post_parent == $MyID ){
myPagesparent($pagg->ID,$MyID);
}else{
$option = '<a href="'.get_page_link($pagg->ID).'">';
$option .= $post->ID;
$option .= $pagg->post_title;
echo '<li>'.$option.'</a></li>';
}
}
}
myPagesparent($post->ID,$post->ID);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question