Skip to content

Instantly share code, notes, and snippets.

@tollmanz
Created May 9, 2012 02:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tollmanz/2641305 to your computer and use it in GitHub Desktop.
Save tollmanz/2641305 to your computer and use it in GitHub Desktop.
wp_list_pluck Example
<?php
// Take from posts-to-posts (http://scribu.net/wordpress/posts-to-posts)
public function get_related( $post_id, $extra_qv = array() ) {
$post_id = (array) $post_id;
$connected = $this->get_connected( $post_id, $extra_qv );
if ( !$connected )
return false;
if ( !$connected->have_posts() )
return $connected;
$connected_ids = wp_list_pluck( $connected->posts, 'ID' );
return $this->get_connected( $connected_ids, array(
'post__not_in' => $post_id,
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment