WordPress.org

Ready to get started?Download WordPress

Forums

problem displaying 3 level deep page hierarchy (2 posts)

  1. pateln54
    Member
    Posted 3 years ago #

    Hi,
    I have created page - "Solutions" , child pages of "Solutions - Design Solutions, Development Solutions & Mobile Solutions" and child pages of each, e.g. "Design solutions - 1. Web Design, 2. Print Design, 3. Logo & Identity, Development Solutions - 1. Web Development, ... etc.
    I want to show only last level pages i.e(web design, print design, web development,..) when I go to "Solutions" Page...
    I tried the code, but it also shows the second level pages like Design Solutions and others. I want to hide them or exclude them, I also tried the wp_list_pages() and get_pages() but not working....
    See the code...

    if(have_posts()) : while(have_posts()) : the_post();
    
    				$parents = get_pages('child_of='.$post->ID.'&parent='.$post->ID.'&hierarchical=0');
    				//$mypages = get_pages('child_of=$parents&exclude=$parents')
    
    				foreach($parents as $parent)
    				{
    					$parent_id[] = $parent->ID;
    				}
    				$value = implode(',', $parent_id);
    
    				//$result = wp_list_pages('child_of='.$post->ID);
    
    				$query = new WP_Query('post_parent='.$post->ID);
    
    				while($query->have_posts()) : $query->the_post();
    					the_title();
    				endwhile;

    ..... so on.....

    I also fetched IDs of those 3 posts and used it in parameters with exclude but didn't work....

    ANY SUGGESTIONS?

  2. MichaelH
    Member
    Posted 3 years ago #

    After this line
    $value = implode(',', $parent_id);
    couldn't this work

    $wlp_param_list='exclude=' . $value;
    wp_list_pages($wlp_param_list);

Topic Closed

This topic has been closed to new replies.

About this Topic