New Landing How can we help? Atelier Display categories in post meta section

Viewing 6 posts - 1 through 6 (of 6 total)
  • Posted in: Atelier
  • #201166
    flavius
    Member
    Post count: 5

    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.

    #201933
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    It’s not currently available, you would need to edit the theme files

    – Kyle

    #201940
    flavius
    Member
    Post count: 5

    Hi Kyle,

    I’m comfortable editing theme files. Any chance you could point me in the right direction?

    #201981
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Go 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

    #202527
    flavius
    Member
    Post count: 5

    Hi 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>’;
    }

    #202599
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Ok great

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register