Digital experiences for all disciplines
New Landing › How can we help? › Atelier › Display categories in post meta section
New Landing › How can we help? › Atelier › Display categories in post meta section
- This topic has 5 replies, 2 voices, and was last updated 9 years by Kyle – SUPPORT.
-
Posted in: Atelier
-
August 5, 2015 at 11:40 pm #201166
Hello,
How do I display each post’s category in the post meta section (under Author) on the blog page and recent posts?
Many thanks.
August 7, 2015 at 2:37 pm #201933Hi
It’s not currently available, you would need to edit the theme files
– Kyle
August 7, 2015 at 2:49 pm #201940Hi Kyle,
I’m comfortable editing theme files. Any chance you could point me in the right direction?
August 7, 2015 at 4:09 pm #201981Go to atelier/swift-framework/content/sf-post-formats.php, find:
// DETAILS SETUP $item_details = ""; if ( $single_author && ! $remove_dates ) { $item_details .= '<div class="blog-item-details">' . sprintf( __( 'In %1$s on <time datetime="%2$s">%3$s</time>', 'swiftframework' ), $post_categories, $post_date_str, $post_date ) . '</div>'; } else if ( ! $remove_dates ) { $item_details .= '<div class="blog-item-details">' . sprintf( __( '<span class="author">By <a href="%2$s" rel="author" itemprop="author">%1$s</a></span> in %3$s on <time datetime="%4$s">%5$s</time>', 'swiftframework' ), $post_author, get_author_posts_url( get_the_author_meta( 'ID' ) ), $post_categories, $post_date_str, $post_date ) . '</div>'; } else if ( ! $single_author ) { $item_details .= '<div class="blog-item-details">' . sprintf( __( '<span class="author">By <a href="%2$s" rel="author" itemprop="author">%1$s</a></span> in %3$s', 'swiftframework' ), $post_author, get_author_posts_url( get_the_author_meta( 'ID' ) ), $post_categories ) . '</div>'; }
– Kyle
August 10, 2015 at 8:50 pm #202527Hi Kyle,
Thanks for your suggestion. I found a better way to display categories which was to copy the sf_get_post_details function from includes/sf-theme-functions.php to the functions.php file in my child theme folder.
I then edited the copied sf_get_post_details function as follows to get categories to appear in the post meta data.
REPLACED:
if ( !$single_author && comments_open() ) {
$post_details .= ‘<div class=”blog-item-details”><span class=”author”>’ . sprintf( __( ‘By %1$s‘, ‘swiftframework’ ), $post_author, get_author_posts_url( get_the_author_meta( ‘ID’ ) ) ) . ‘</span>’;
if ( $recent_post ) {
$post_details .= ‘ / <span>’. $comments .'</span>’;
}
$post_details .= ‘</div>’;
} else if ( $single_author && comments_open() ) {
$post_details .= ‘<div class=”post-item-details”><span>’. $comments .'</span></div>’;
} else {
$post_details .= ‘<span class=”author”>’ . sprintf( __( ‘By %1$s‘, ‘swiftframework’ ), $post_author, get_author_posts_url( get_the_author_meta( ‘ID’ ) ) ) . ‘</span>’;
}WITH:
if ( !$single_author && comments_open() ) {
$post_details .= ‘<div class=”blog-item-details”><span class=”author”>’ . sprintf( __( ‘By %1$s‘, ‘swift framework’ ), $post_author, get_author_posts_url( get_the_author_meta( ‘ID’ ) ) ) . ‘ in ‘ . $post_categories . ‘</span>’;
if ( $recent_post ) {
$post_details .= ‘<span class=”comments”> / ‘. $comments .'</span>’;
}
$post_details .= ‘</div>’;
} else if ( $single_author && comments_open() ) {
$post_details .= ‘<div class=”post-item-details”><span>’. $comments .'</span></div>’;
} else {
$post_details .= ‘<span class=”author”>’ . sprintf( __( ‘By %1$s‘, ‘swift framework’ ), $post_author, get_author_posts_url( get_the_author_meta( ‘ID’ ) ) ) . ‘ in ‘ . $post_categories . ‘</span>’;
}August 11, 2015 at 8:05 am #202599Ok great
-
Posted in: Atelier
You must be logged in and have valid license to reply to this topic.