From 9997d8268e22e9616cea1070a701e6c7057b6977 Mon Sep 17 00:00:00 2001 From: Pea Date: Tue, 11 Apr 2017 16:38:36 -0400 Subject: [PATCH 1/4] Updated related posts shortcode --- includes/class-tni-core-shortcodes.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/includes/class-tni-core-shortcodes.php b/includes/class-tni-core-shortcodes.php index 0edebad..d1552d0 100644 --- a/includes/class-tni-core-shortcodes.php +++ b/includes/class-tni-core-shortcodes.php @@ -185,7 +185,7 @@ public function margin_right_shortcode( $attr, $content = null ) { * * @since 1.0.6 * - * @todo Add template loader to allow template to be modified in the theme + * @todo Add template loader to allow template to be modified in the theme * * @uses Jetpack_RelatedPosts * @link https://jetpack.com/support/related-posts/customize-related-posts/ @@ -202,17 +202,20 @@ public function jetpack_related_posts_shortcode( $atts ) { ); if ( $related ) { + global $post; foreach ( $related as $result ) { - $related_post = get_post( $result[ 'id' ] ); - $thumb = get_the_post_thumbnail( $related_post->ID, 'thumbnail' ); - $category = get_the_category( $related_post->ID )[0]; - $author = get_the_author_meta( 'display_name', $related_post->post_author ); - $author_url = get_author_posts_url( $related_post->post_author ); - $subhead = get_post_meta( $related_post->ID, 'post_subhead', true ); + $post = get_post( $result[ 'id' ] ); + setup_postdata( $post ); + + $thumb = get_the_post_thumbnail( $post->ID, 'thumbnail' ); + $category = get_the_category( $post->ID )[0]; + $author = get_the_author_meta( 'display_name', $post->post_author ); + $author_url = get_author_posts_url( $post->post_author ); + $subhead = get_post_meta( $post->ID, 'post_subhead', true ); if ( !$subhead ) { - $subhead = get_the_excerpt( $related_post->ID ); + $subhead = get_the_excerpt( $post->ID ); } - $permalink = get_permalink( $related_post->ID ); + $permalink = get_permalink( $post->ID ); ob_start(); @@ -220,6 +223,7 @@ public function jetpack_related_posts_shortcode( $atts ) { $related_html .= ob_get_clean(); } + wp_reset_postdata(); } } return '
' . $related_html . '
'; From c1212abcd28b470ec09ac5085bc4742f392c5713 Mon Sep 17 00:00:00 2001 From: Pea Date: Tue, 11 Apr 2017 16:38:54 -0400 Subject: [PATCH 2/4] Added template tag for getting authors --- includes/template-tags.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 includes/template-tags.php diff --git a/includes/template-tags.php b/includes/template-tags.php new file mode 100644 index 0000000..66e0dc7 --- /dev/null +++ b/includes/template-tags.php @@ -0,0 +1,38 @@ +' . __( 'By ', 'tni' ), '', false ); + } else { + $author_string = sprintf( '%s', + __( 'By ', 'tni' ), + esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), + esc_attr( sprintf( esc_html__( 'View all posts by %s', 'tni' ), + get_the_author() ) ), + esc_html( get_the_author() ) + ); + } + + return ' ' . $author_string . ''; + } From 308cb77e4408482d964b6d233f98c390b3309e57 Mon Sep 17 00:00:00 2001 From: Pea Date: Tue, 11 Apr 2017 16:39:17 -0400 Subject: [PATCH 3/4] Updated template to use WP template tag --- templates/related-posts.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/templates/related-posts.php b/templates/related-posts.php index 8d7ebd3..13a1f41 100644 --- a/templates/related-posts.php +++ b/templates/related-posts.php @@ -12,19 +12,24 @@
- - + + + +

- - post_title ); ?> + +

From c6d19367dd0364f436d9715c60e67453bf9cea6c Mon Sep 17 00:00:00 2001 From: Pea Date: Tue, 11 Apr 2017 16:39:53 -0400 Subject: [PATCH 4/4] #19 Added Co-authors Plus support https://github.com/thenewinquiry/tni-theme/issues/19 --- readme.txt | 5 ++++- tni-core-functionality.php | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index ca2ff9c..f07575b 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: misfist Tags: custom Requires at least: 4.7 Tested up to: 4.7.2 -Version: 1.0.7 +Version: 1.0.8 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -22,6 +22,9 @@ This section describes how to install the plugin and get it working. == Changelog == += 1.0.8 April 11, 2017 = +* Added Co-authors Plus support to Related Posts + = 1.0.7 April 7, 2017 = * Removed unused featured content option page * Removed form processor diff --git a/tni-core-functionality.php b/tni-core-functionality.php index b7b03b9..b320abb 100644 --- a/tni-core-functionality.php +++ b/tni-core-functionality.php @@ -10,7 +10,7 @@ * Text Domain: tni-core * Domain Path: /languages * - * Version: 1.0.7 + * Version: 1.0.8 * * @package Tni_Core_Functionality */ @@ -26,6 +26,7 @@ define( 'TNI_CORE_DIR_URL', plugin_dir_url( __FILE__ ) ); require_once( 'includes/helpers.php' ); +require_once( 'includes/template-tags.php' ); // Load plugin class files require_once( 'includes/class-tni-core.php' ); @@ -44,7 +45,7 @@ * @return object Tni_Core */ function Tni_Core() { - $instance = Tni_Core::instance( __FILE__, '1.0.7' ); + $instance = Tni_Core::instance( __FILE__, '1.0.8' ); return $instance; }