[Resolved] Disabling linking to author's posts

Home Forums Support Disabling linking to author's posts

Viewing 15 posts - 1 through 15 (of 34 total)
  • Author
    Posts
  • #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

    #110297
    Tom
    Lead Developer
    Lead Developer
    #110338
    Remez 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

    #110395
    Tom
    Lead Developer
    Lead Developer

    I just tested it and it worked.

    Did you add it to your child theme’s functions.php?

    #110415
    Remez 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&#8221; itemscope=”itemscope” itemprop=”author”>%1$s <span class=”author-name” itemprop=”name”>%2$s</span></span>’,
    __( ‘by’,’generate’),
    esc_html( get_the_author() )
    )
    );
    }
    endif;

    #110416
    Tom
    Lead Developer
    Lead Developer

    Try 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.

    #110419
    Remez 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

    #110493
    Tom
    Lead Developer
    Lead Developer

    That’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! 🙂

    #135997
    Sha

    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.

    #136056
    Tom
    Lead Developer
    Lead Developer

    Are 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

    #137548
    Maximus 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!

    #137549
    Tom
    Lead Developer
    Lead Developer
    #138557
    Alexander

    It works for me on Pages, but not on Post-Pages. Is there an other Filter for it?

    #138558
    Tom
    Lead Developer
    Lead Developer

    Authors don’t show up on pages, only posts.

    This is the only function/filter that applies to authors in the theme.

    #138574
    Alexander

    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;
    
Viewing 15 posts - 1 through 15 (of 34 total)
  • You must be logged in to reply to this topic.