[Resolved] adjusting post meta in child theme

Home Forums Support [Resolved] adjusting post meta in child theme

Home Forums Support adjusting post meta in child theme

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1872535
    manaadiar

    Hi there.. I am looking for an option to remove the “by” before the Author.. I would like to also bring the author icon and name to the next line below Date Posted On and above Categories..

    adjusting post meta..

    While this is possible to change in the parent theme in Line 213 by removing %1$s and entering a <br> before the <span class=”author%8$s”……………, it doesn’t work in the child theme because this line of code is not there in the child theme..

    $byline = ‘<span class=”byline”>%1$s<span class=”author%8$s” %5$s><span class=”author-name”%7$s>%4$s</span></span></span> ‘;

    Pls let me know how this can be achieved..

    #1873544
    Ying
    Staff
    Customer Support

    Hi there,

    Try this filter to remove the “by”:

    add_filter( 'generate_post_author_output', 'tu_change_author_by_text' );
    function tu_change_author_by_text() {
    	printf( ' <span class="byline">%1$s</span>',
    		sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"> <a class="url fn n" href="%1$s" title="%2$s" rel="author" itemprop="url"><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() )
    		)
    	);
    }

    To move the author to next line, try this CSS:

    .entry-meta .byline {
        display: block;
    }
    #1873966
    manaadiar

    Hi Ying, the function filter worked, but below code didn’t work for creating line break..

    .entry-meta .byline {
    display: block;
    }

    So I added a <br> in the function itself as below and its working fine now.. Thanks..

    //code to eliminate by in the post-meta

    add_filter( ‘generate_post_author_output’, ‘tu_change_author_by_text’ );
    function tu_change_author_by_text() {
    printf( ‘ <span class=”byline”>%1$s</span>’,
    sprintf( ‘<br><span class=”author vcard” itemtype=”http://schema.org/Person&#8221; itemscope=”itemscope” itemprop=”author”><span class=”author-name” itemprop=”name”>%3$s</span></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() )
    )
    );
    }

    #1874003
    Elvin
    Staff
    Customer Support

    Hi there,

    I believe this is the aim? https://share.getcloudapp.com/bLukXwqv

    If so, try this CSS:

    .entry-meta {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .entry-meta > span {
        flex: 1 0 100%;
    }
    #1874026
    manaadiar

    Nope, didn’t work.. So reverted my solution..

    #1875142
    Elvin
    Staff
    Customer Support

    have you sorted it out? It looks fine now on my end as shown here – https://share.getcloudapp.com/nOuv6g8x

    Let us know if you need further help with it. ๐Ÿ˜€

    #1875271
    manaadiar

    Hi Elvin, yes it is now sorted thanks..

    #1875342
    Elvin
    Staff
    Customer Support

    Nice one! Thanks for letting us know. Glad you got it sorted. ๐Ÿ˜€

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