Created
May 9, 2012 02:25
-
-
Save tollmanz/2641305 to your computer and use it in GitHub Desktop.
wp_list_pluck Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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