- This topic has 33 replies, 6 voices, and was last updated 4 years, 5 months ago by
Tom.
-
AuthorPosts
-
May 25, 2015 at 9:02 pm #110270
Remez Sasson
I would like to disable the link in the post’s author name, beneath the title of the post.
I want author’s name to remain, but I don’t want it to be a link. Currently the link leads to all the author’s posts.
Thank you
May 25, 2015 at 11:22 pm #110297Tom
Lead DeveloperLead DeveloperAdding this function should do the trick: https://gist.github.com/generatepress/67fb28af5c8be3103290
Adding PHP: http://generatepress.com/knowledgebase/adding-php-functions/
May 26, 2015 at 2:55 am #110338Remez Sasson
I added the code in the link above, https://gist.github.com/generatepress/67fb28af5c8be3103290 to the functions.php file, but then my blog went blank, so I removed it.
Can you help please?
Thank you
Remez
May 26, 2015 at 8:22 am #110395Tom
Lead DeveloperLead DeveloperI just tested it and it worked.
Did you add it to your child theme’s functions.php?
May 26, 2015 at 9:31 am #110415Remez Sasson
I added the following script again, as per the link above, a few minutes ago, but the author’s name beneath the title is still a link.
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;$time_string = ‘<time class=”entry-date published” datetime=”%1$s” itemprop=”datePublished”>%2$s</time>’;
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() )
);printf( __( ‘<span class=”posted-on”>%1$s</span> <span class=”byline”>%2$s</span>’, ‘generate’ ),
sprintf( ‘%3$s‘,
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
$time_string
),
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;May 26, 2015 at 9:33 am #110416Tom
Lead DeveloperLead DeveloperTry adding it using this plugin: https://wordpress.org/plugins/code-snippets/
Just a note for others, don’t use the code pasted above – use the code I originally linked to.
May 26, 2015 at 10:15 am #110419Remez Sasson
I didn’t want to add another plugin to the blog, so I tried again inserting the code you supplied to the child theme functions.php, but this time i did not upload it with trough ftp, but pasted into the functions.php through the editor in WordPress, and it worked, removing the link.
I don’t understand why it didn’t work by uploading it through ftp, but the important thing is that this issue is solved now.
Thank you for your help,
Remez Sasson
May 26, 2015 at 11:05 pm #110493Tom
Lead DeveloperLead DeveloperThat’s very odd – I can’t think of a reason why FTP wouldn’t work, it’s actually more reliable than other methods.
Either way, glad it worked! ๐
September 11, 2015 at 4:59 am #135997Sha
Hi Tom,
I pasted the above code to theme’s function.php.
Yet, author link is click-able.Am i doing anything wrong?
Also, how can i disable the link on the date.
Thank You.
September 11, 2015 at 9:09 am #136056Tom
Lead DeveloperLead DeveloperAre you using a child theme? If so, is the filed name functions.php (with an s)?
This function will remove the link to the date and author: https://gist.github.com/generatepress/17e92621b6bf1140dafa
September 17, 2015 at 11:14 am #137548Maximus Peto
Just some feedback: I also wanted to remove the link to the author profile (so as to hide my username), but leave the author name there in post metadata. I used Tom’s suggestion to create a plugin with Pluginception.
I made the plugin, pasting exactly the code Tom linked to at: https://gist.github.com/generatepress/67fb28af5c8be3103290.
It worked perfectly! Thanks!
September 17, 2015 at 11:15 am #137549Tom
Lead DeveloperLead DeveloperPerfect! Glad it worked ๐
September 21, 2015 at 10:55 am #138557Alexander
It works for me on Pages, but not on Post-Pages. Is there an other Filter for it?
September 21, 2015 at 11:06 am #138558Tom
Lead DeveloperLead DeveloperAuthors don’t show up on pages, only posts.
This is the only function/filter that applies to authors in the theme.
September 21, 2015 at 12:06 pm #138574Alexander
There is a Problem, these two filters do not work together:
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; $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>'; 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() ) ); printf( __( '<span class="posted-on">%1$s</span> <span class="byline">%2$s</span>', 'generate' ), sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>', esc_url( get_permalink() ), esc_attr( get_the_time() ), $time_string ), 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;
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 <a class="url fn n" href="%2$s" title="%3$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%4$s</span></a></span>', __( 'by','generate'), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_attr( sprintf( __( 'View all posts by %s', 'generate' ), get_the_author() ) ), esc_html( get_the_author() ) ) ); } endif;
-
AuthorPosts
- You must be logged in to reply to this topic.