- This topic has 33 replies, 6 voices, and was last updated 4 years, 11 months ago by Tom.
-
AuthorPosts
-
September 21, 2015 at 11:10 pm #138664TomLead DeveloperLead Developer
If you add both, it will only read the latest instance of it (the second one).
September 22, 2015 at 2:33 am #138702AlexanderI would like that both are gone, the Author Link, and Post-Date, but that does not work for me.
September 22, 2015 at 10:19 am #138788TomLead DeveloperLead DeveloperThis 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;
September 22, 2015 at 10:37 am #138792AlexanderIs there a way that I can remove both (Author Link & Post-Date) complete from Code?
September 22, 2015 at 11:32 am #138809TomLead DeveloperLead DeveloperThe 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).
July 5, 2016 at 10:57 am #206745DanyWell 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.July 5, 2016 at 11:36 pm #206874TomLead DeveloperLead DeveloperThat’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 ๐
August 20, 2017 at 10:23 pm #370150SucomiHello Tom,
It’s worked for disabling link author. Thank you!
But i need another code disabling link for dates too. Please help.
August 20, 2017 at 11:58 pm #370185TomLead DeveloperLead DeveloperTo 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() ) ) ); }
August 21, 2017 at 3:21 am #370296SucomiThank you so much!
August 21, 2017 at 9:39 am #370518TomLead DeveloperLead DeveloperYou’re welcome ๐
April 18, 2019 at 7:32 pm #873109ErickaHi 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?
April 19, 2019 at 8:58 am #873626TomLead DeveloperLead DeveloperHi there,
Do you have any other functions using the
generate_post_date_output
filter?April 19, 2019 at 9:06 am #873634ErickaNo, 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” 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;April 19, 2019 at 9:16 am #873645TomLead DeveloperLead DeveloperThat code is the issue. You can likely ditch it and do this: https://docs.generatepress.com/article/show-the-updated-post-date/
-
AuthorPosts
- You must be logged in to reply to this topic.