From b69638db207c3ef9999f72e1555df5dc560ef996 Mon Sep 17 00:00:00 2001 From: Takumi Date: Fri, 26 Jul 2013 15:22:14 +1000 Subject: [PATCH] Fix issue of delimiter not showing when same teams competing in event --- helpers.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/helpers.php b/helpers.php index eb8fe18f..d90a2e05 100644 --- a/helpers.php +++ b/helpers.php @@ -67,11 +67,13 @@ if ( ! function_exists( 'sp_dropdown_taxonomies' ) ) { } if ( ! function_exists( 'sp_the_posts' ) ) { - function sp_the_posts( $post_id = null, $meta = 'post', $before = '', $sep = ', ', $after = '' ) { + function sp_the_posts( $post_id = null, $meta = 'post', $before = '', $sep = ', ', $after = '', $delimiter = '— ' ) { echo $before; if ( ! isset( $post_id ) ) global $post_id; $posts = get_post_meta( $post_id, $meta, false ); + $i = 0; + $count = count( $posts ); if ( isset( $posts ) && $posts && is_array( $posts ) ): foreach ( $posts as $post ): $parents = get_post_ancestors( $post ); @@ -79,11 +81,12 @@ if ( ! function_exists( 'sp_the_posts' ) ) { foreach ( $parents as $parent ): if ( !in_array( $parent, $posts ) ) edit_post_link( get_the_title( $parent ), '', ' ', $parent ); - echo '— '; + echo $delimiter; endforeach; edit_post_link( get_the_title( $post ), '', '', $post ); - if ( $post != end( $posts ) ) + if ( ++$i !== $count ) { echo $sep; + } endforeach; endif; echo $after;