View difference between Paste ID: vkMRQuRF and GsyaeeaF
SHOW: | | - or go back to the newest paste.
1-
                    	<?php
1+
<?php
2-
							//if the post has a parent
2+
	//if the post has a parent
3-
							if($post->post_parent){
3+
	if($post->post_parent){
4-
  							//collect ancestor pages
4+
  	//collect ancestor pages
5-
  							$relations = get_post_ancestors($post->ID);
5+
  	$relations = get_post_ancestors($post->ID);
6-
  							//get child pages
6+
  	//get child pages
7-
  							$result = $wpdb->get_results( "SELECT ID FROM wp_posts WHERE post_parent = $post->ID AND post_type='page'" );
7+
  	$result = $wpdb->get_results( "SELECT ID FROM wp_posts WHERE post_parent = $post->ID AND post_type='page'" );
8-
  								if ($result){
8+
  	if ($result){
9-
    								foreach($result as $pageID){
9+
    		foreach($result as $pageID){
10-
      									array_push($relations, $pageID->ID);
10+
      			array_push($relations, $pageID->ID);
11-
    								}
11+
    		}
12-
  								}
12+
  	}
13-
  							//add current post to pages
13+
  		//add current post to pages
14-
  							array_push($relations, $post->ID);
14+
  		array_push($relations, $post->ID);
15-
  							//get comma delimited list of children and parents and self
15+
  		//get comma delimited list of children and parents and self
16-
  							$relations_string = implode(",",$relations);
16+
  		$relations_string = implode(",",$relations);
17-
  							//use include to list only the collected pages. 
17+
  		//use include to list only the collected pages. 
18-
  							$sidelinks = wp_list_pages("title_li=&echo=0&include=".$relations_string);
18+
  		$sidelinks = wp_list_pages("title_li=&echo=0&include=".$relations_string);
19-
							}else{
19+
	}else {
20-
 							// display only main level and children
20+
 		// display only main level and children
21-
  							$sidelinks = wp_list_pages("title_li=&echo=0&depth=3&child_of=".$post->ID);
21+
  		$sidelinks = wp_list_pages("title_li=&echo=0&depth=3&child_of=".$post->ID);
22-
							}
22+
	}
23
24-
							if ($sidelinks) { ?>
24+
	if ($sidelinks) { ?>
25-
 								<ul class="left-nav">
25+
 		<ul class="left-nav">
26-
                                	<li><a class="stand-alone" href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></li>
26+
                	<li><a class="stand-alone" href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></li>
27-
    								<?php //links in <li> tags
27+
    		<?php //links in <li> tags
28-
    								echo $sidelinks; ?>
28+
    			echo $sidelinks; ?>
29-
  								</ul> 
29+
  		</ul> 
30-
							<?php } 
30+
	<?php } 
31-
								else { ?>
31+
	else { ?>
32-
									<ul class="left-nav">
32+
		<ul class="left-nav">
33-
                       				<li><a class="stand-alone" href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></li>
33+
                	<li><a class="stand-alone" href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></li>
34-
                                    </ul>
34+
                </ul>
35-
                            <?php } ?>
35+
         <?php } ?>