Cyber Week Sale! Get $20 off GP Premium, $40 off our new Lifetime license, and 45% off license renewals/extensions! Learn more

[Resolved] Disabling linking to author's posts

Home Forums Support Disabling linking to author's posts

Viewing 15 posts - 16 through 30 (of 34 total)
  • Author
    Posts
  • #138664
    Tom
    Lead Developer
    Lead Developer

    If you add both, it will only read the latest instance of it (the second one).

    #138702
    Alexander

    I would like that both are gone, the Author Link, and Post-Date, but that does not work for me.

    #138788
    Tom
    Lead Developer
    Lead Developer

    This function should only show the author with no link – nothing else:

    if ( ! function_exists( 'generate_posted_on' ) ) :
    /**
     * Prints HTML with meta information for the current post-date/time and author.
     */
    function generate_posted_on() {
    
    	if ( 'post' !== get_post_type() )
    		return;
    
    	printf( __( '<span class="byline">%1$s</span>', 'generate' ),
    		sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s <span class="author-name" itemprop="name">%2$s</span></span>',
    			__( 'by','generate'),
    			esc_html( get_the_author() )
    		)
    	);
    }
    endif;
    #138792
    Alexander

    Is there a way that I can remove both (Author Link & Post-Date) complete from Code?

    #138809
    Tom
    Lead Developer
    Lead Developer

    The above code will remove the post date and the link to the author from the code.

    The only thing it will display is the author name (no link).

    #206745
    Dany

    Well guys, I don’t bother with adding any extra codes to anywhere.

    I just simply find the lines in the theme codes which are pertinent to the date and author and I just remove them.
    I’ve been doing this for a long time with many of many themes, works every time.

    The only downside is that when the theme is updated sometimes you have to do it again – or just upload your edited code. (depends on the theme/update).
    But since I am paranoid I keep many dated backups (even as plain files!) on my local machines anyway, so it’s not a problem.

    #206874
    Tom
    Lead Developer
    Lead Developer

    That’s one way, Dany. The downside is as you said, having to re-do it every time.

    The way I’ve outlined makes it so you only ever have to do it once 🙂

    #370150
    Sucomi

    Hello Tom,

    It’s worked for disabling link author. Thank you!

    But i need another code disabling link for dates too. Please help.

    #370185
    Tom
    Lead Developer
    Lead Developer

    To remove the link from dates, you would do this:

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

    To remove the link from the author, you would do this:

    add_filter( 'generate_post_author_output','tu_no_author_link' );
    function tu_no_author_link() {
    	printf( ' <span class="byline">%1$s</span>',
    		sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s <span class="fn n author-name" itemprop="name">%4$s</span></span>',
    			__( 'by','generatepress'),
    			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() )
    		)
    	);
    }
    #370296
    Sucomi

    Thank you so much!

    #370518
    Tom
    Lead Developer
    Lead Developer
    #873109
    Ericka

    Hi Tom! I use the following code through Code Snippet to remove the link from dates:

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

    BUT it’s not working. Is it because I’m using another code so my post only show the las update? Or what im doing wrong?

    #873626
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Do you have any other functions using the generate_post_date_output filter?

    #873634
    Ericka

    No, just the code to show the Last Update in my posts. Specifically this one:

    if ( ! function_exists( ‘generate_posted_on’ ) ) :
    /**
    * Prints HTML with meta information for the current post-date/time and author.
    */
    function generate_posted_on()
    {
    $date = apply_filters( ‘generate_post_date’, true );
    $author = apply_filters( ‘generate_post_author’, true );
    //if ( get_the_time( ‘U’ ) !== get_the_modified_time( ‘U’ ) )
    $time_string .= ‘<time class=”updated” datetime=”%3$s” itemprop=”dateModified”>%4$s</time>’;
    $time_string = sprintf( $time_string,
    esc_attr( get_the_date( ‘c’ ) ),
    esc_html( get_the_date() ),
    esc_attr( get_the_modified_date( ‘c’ ) ),
    esc_html( get_the_modified_date() )
    );

    // If our date is enabled, show it
    if ( $date ) :
    printf( ‘<span style=”float: left; margin-right: 3px;”>Actualizado:</span><span class=”posted-on”>%1$s</span>’,
    sprintf( ‘%3$s‘,
    esc_url( get_permalink() ),
    esc_attr( get_the_time() ),
    $time_string
    )
    );
    endif;

    // If our author is enabled, show it
    if ( $author ) :
    printf( ‘ <span class=”byline”>%1$s</span>’,
    sprintf( ‘<span class=”author vcard” itemtype=”http://schema.org/Person&#8221; itemscope=”itemscope” itemprop=”author”>%1$s <span class=”author-name” itemprop=”name”>%4$s</span></span>’,
    __( ‘by’,’generatepress’),
    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() )
    )
    );
    endif;

    }
    endif;

    #873645
    Tom
    Lead Developer
    Lead Developer
Viewing 15 posts - 16 through 30 (of 34 total)
  • You must be logged in to reply to this topic.