[Resolved] Meta Style Question

Home Forums Support [Resolved] Meta Style Question

Home Forums Support Meta Style Question

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #1111525
    Chris

    1. First, I’ve read this article: https://docs.generatepress.com/article/entry-meta-style/. When it says ‘add this PHP snippet’: http://prntscr.com/qeehh3, does that mean I apply the code inside ‘Custom CSS’
    2. I’d like my byline underneath the title to read like this:

    By Name | Date

    #1111527
    Leo
    Staff
    Customer Support

    Hi there,

    1. Adding PHP: https://docs.generatepress.com/article/adding-php/

    2. Let’s try the snippet in the doc article first.

    #1111544
    Chris

    So do I just copy this code:

    add_filter( 'generate_post_author_output', function() {
        return sprintf( ' <span class="byline">%1$s</span>',
            sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%4$s<a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a></span>',
                esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
                esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
                esc_html( get_the_author() ),
                get_avatar( get_the_author_meta( 'ID' ) )
            )
        );
    } );
    
    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
            'author',
            'comments-link',
            'date',
        );
    } );
    
    add_filter( 'generate_footer_entry_meta_items', function( $items ) {
        return array(
            'date',
            'categories',
        );
    } );

    And paste it at the end of function.php like this: http://prntscr.com/qeeqez

    #1111549
    Chris

    If so, could you modify the code where the end result looks like this:

    By: Name | Date

    #1111810
    Tom
    Lead Developer
    Lead Developer

    To do that, try this:

    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
            'author',
            'date',
        );
    } );
    
    add_filter( 'generate_inside_post_meta_item_output', function( $output, $type ) {
        if ( 'author' === $type ) {
            $output = 'By: ';
        }
    
        if ( 'date' === $type ) {
            $output = ' | ';
        }
    
        return $output;
    }, 10, 2 );

    Let me know πŸ™‚

    #1112092
    Chris

    Hey Tom,

    I pasted your code and now my site (more specifically, blog posts) are receiving this error:

    Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure}(), 1 passed in /home/customer/www/test.com/public_html/wp-includes/class-wp-hook.php on line 290 and exactly 2 expected in

    #1112490
    Tom
    Lead Developer
    Lead Developer

    Sorry about that – can you try now?

    #1112659
    Chris

    No worries πŸ™‚ That worked! How could I remove the links from author and date?

    For example, it says “by [name] | [date]”

    The name links to my author bio. And the date links to the post.

    How could I remove both links?

    #1112765
    Leo
    Staff
    Customer Support
    #1112775
    Chris

    The ‘Remove Link’ from Author byline worked.

    However, when I add the code to remove link from date:

    add_filter( 'generate_post_date_output', function( $output, $time_string ) {
    	printf( '<span class="posted-on">%s</span>',
    		$time_string
    	);
    }, 10, 2 );

    it removes the separator between name and date. For example:

    Original: by Name | Date
    After removing link from date: by namedate

    #1113333
    David
    Staff
    Customer Support

    Hi there,

    you can edit this part of the code:

    <span class="posted-on">%s</span> to include the extra content eg.

    <span class="posted-on"> | %s</span>

    #1113335
    Chris

    That worked! Thanks David πŸ™‚

    However, I came across another issue:

    Whenever I update the post, the date remains the same as the original publish date.

    For example, I published an article yesterday (December 23, 2019). Today, I modified the article and clicked “Update”.

    When I view the post, the date still shows as December 23, 2019. Instead, it should’ve updated with December 24, 2019.

    #1113423
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Have you set it up so the updated date displays?: https://docs.generatepress.com/article/show-the-updated-post-date/

    #1113466
    Chris

    Perfect, thank you!

    Awesome support from Leo, David, and Tom! Thanks a bunch guys!!

    #1113549
    Tom
    Lead Developer
    Lead Developer

    Glad we could help πŸ™‚

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.