Modify function to retrieve multiple posts from single meta key

This commit is contained in:
Takumi
2013-07-26 00:36:30 +10:00
parent 1edf37c310
commit f600617fc1
2 changed files with 4 additions and 5 deletions

View File

@@ -65,14 +65,13 @@ if ( ! function_exists( 'sp_dropdown_taxonomies' ) ) {
}
}
}
if ( ! function_exists( 'sp_unserialized_posts' ) ) {
function sp_unserialized_posts( $post_id = null, $meta = 'posts', $before = '', $sep = ',', $after = '' ) {
if ( ! function_exists( 'sp_the_posts' ) ) {
function sp_the_posts( $post_id = null, $meta = 'post', $before = '', $sep = ',', $after = '' ) {
echo $before;
if ( ! isset( $post_id ) )
global $post_id;
$posts = get_post_meta( $post_id, $meta, true );
$posts = get_post_meta( $post_id, $meta, false );
if ( isset( $posts ) && $posts ):
$posts = (array)unserialize( $posts );
foreach ( $posts as $post ):
$parents = get_post_ancestors( $post );
$parents = array_combine( array_keys( $parents ), array_reverse( array_values( $parents ) ) );

View File

@@ -59,7 +59,7 @@ function sp_player_custom_columns( $column, $post_id ) {
echo '—';
break;
case 'sp_team':
sp_unserialized_posts( $post_id, 'sp_teams', '', '<br />' );
sp_the_posts( $post_id, 'sp_team', '', '<br />' );
break;
case 'sp_league':
if ( get_the_terms ( $post_id, 'sp_league' ) )