Return to Snippet

Revision: 30370
at March 21, 2011 20:12 by zartgesotten


Updated Code
<?php
    global $wp_query;
    if( empty($wp_query->post->post_parent) ) 
      {
         $parent = $wp_query->post->ID;
      } 
    else 
     {
         $parent = $wp_query->post->post_parent;
     } ?>
   
<?php if(wp_list_pages("title_li=&child_of=$parent&echo=0" )): ?>
    <ul class="submenus">
      <?php wp_list_pages("title_li=&child_of=$parent" ); ?>
     </ul>

<?php endif; ?>

Revision: 30369
at August 13, 2010 00:38 by zartgesotten


Initial Code
<?php
					    global $wp_query;
						global $post;     // if outside the loop
					    //$parent = $wp_query->post->ID;
						$current = $post->ID;
						$parent = $post->post_parent;
						$grandparent_get = get_post($parent);
						$grandparent = $grandparent_get->post_parent;
				?>
						
		   		   	
						<hr />
							
							<?php 
							echo "Parent: $parent<br>";
							echo "Grandparent: $grandparent" ?>
					
							
							<?php if(empty($grandparent))
							{
							$entrypoint=$current;
							}
							else
							{
							$entrypoint=$parent;
							}
							?>
							    <? if(!empty($parent)) { ?>
								<div id="submenu">
								<h2>Submenu</h2>
								     <ul>
										<?php wp_list_pages("title_li=&child_of=$entrypoint" ); ?>
								     </ul>
							    </div>
								<?php } ?>

Initial URL

                                

Initial Description
This is what I wanted:\r\nI had a structure like this:\r\n-Artist\r\n  --Peter Miller\r\n     ---Pictures\r\n     ---Press\r\n     ---Videos\r\n\r\nand wanted to have the sub-sub-Menu when located on the \"Peter Miller\"-Page. \r\nSo that on \"Peter Miller\" you\'d have \"Pictures, Press and Videos\"-Menu and also on the sibling pages but not on Artists-Page!

Initial Title
Wordpress 2nd Level Menu Subpages

Initial Tags
php, wordpress, code

Initial Language
PHP