Advertisement
sscovil

Revised wpq_index Shortcode Function

Oct 20th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. add_shortcode( 'wpq_index', 'mnsp_wpq_index' );
  2. function mnsp_wpq_index() {
  3.     // Get the ID of the current page/post, to exclude from list
  4.     global $post;
  5.     $current = $post->ID;
  6.    
  7.     // Get results from Shaun's WP Query Shortcode
  8.     global $shauns_wp_query;
  9.  
  10.     $output = '<ul class="related-pages">';
  11.  
  12.     // Begin 'The Loop'
  13.     while( $shauns_wp_query->have_posts() ) : $shauns_wp_query->the_post();
  14.        
  15.         if( $post->ID !== $current )
  16.             $output .= '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
  17.        
  18.     endwhile;
  19.  
  20.     $output .= '</ul>';
  21.  
  22.     return $output;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement