This topic has 1 reply, 2 voices, and was last updated 9 years by sharmstr.

  • Author
  • #69627
     maelga
    Participant

    Hi,

    I am not using the “standard” layout to display custom post types (not the masonry layout).

    Due to the small space constraints most author names takes 2 lines.
    Instead of showing the full name, how can I display only the First Name and initial (first letter) of the last name?

    I’ve tried to edit my archive-customposttype.php to implement this

    COPY CODE
    <?php echo the_author_meta('first_name'); ?>
    <?php echo ('&nbsp;'); ?>
    <?php echo substr(get_the_author_meta('last_name'),0,1).'.'; ?>

    but the code is quite tricky calling for a specific class:

    COPY CODE
    <?php
    //Specific class for post listing
    $blog_type = sq_option('blog_type','masonry');
    $blog_type = apply_filters( 'kleo_blog_type', $blog_type );
    
    $template_classes = $blog_type . '-listing';
    if ( sq_option( 'blog_meta_status', 1 ) == 1 ) {
        $template_classes .= ' with-meta';
    } else {
        $template_classes .= ' no-meta';
    }
    if ( $blog_type == 'standard' && sq_option('blog_standard_meta', 'left' ) == 'inline' ) {
        $template_classes .= ' inline-meta';
    }
    add_filter('kleo_main_template_classes', create_function('$cls','$cls .=" posts-listing ' . $template_classes . '"; return $cls;'));
    ?>

    How can I change these author meta or implement my above snippet to display the last name’s initial only?

    #69639
     sharmstr
    Moderator

    You need to be changing the kleo_entry_meta function in /kleo/functions.php. Copy it to your child theme first. It uses get_the_author so you’ll need to change that.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

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

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?