Home Forums WoodMart support forum How to remove a link to author page from a single blog page?

How to remove a link to author page from a single blog page?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #676929

    markmur
    Participant

    Hello,
    I’ll explain with an example.

    Here is a blog post page: https://woodmart.xtemos.com/2016/07/23/minimalist-design-furniture-2016/

    Under the title of the page Minimalist design furniture 2024, it says:
    Posted by S. Rogers on July 23, 2016.

    S. Rogers is a link to: https://woodmart.xtemos.com/author/admin/

    For SEO purposes, I need to remove the link to https://woodmart.xtemos.com/author/admin/ and just leave the author name S. Rogers, or completely remove both the link and the author name.

    I’ve checked the theme settings but couldn’t find a way to remove it. Could you please advise me how to do this?

    Can you also write a WordPress filter (add_filter()) that I can add to the functions.php file of my child theme to remove the link and leave only the author name S. Rogers, or completely remove both the link and the author name?

    Kind regards,

    #676999

    Hello,

    Please try using the below Custom CSS code and paste it to Dashboard >> Theme Settings >> Custom CSS >> Global CSS section:

    .wd-meta-author {
        display: none !important;
    }

    Best Regards,

    #677084

    markmur
    Participant

    Thank you for your CSS code, but the HTML code of the page still contains a link to the author page: site.com/author/admin/.

    I would like to suggest a better solution for everyone who might need it.

    The function that adds the link to the author page is defined in the file:
    woodmart\inc\template-tags\template-tags.php, lines 661–679:

    if ( ! function_exists( 'woodmart_post_meta_author' ) ) {
    	function woodmart_post_meta_author( $avatar = true, $label = 'short', $author_name = true, $size = 18 ) {
    		?>
    		<?php if ( 'short' === $label ) : ?>
    			<span><?php esc_html_e( 'By', 'woodmart' ); ?></span>
    		<?php elseif ( 'long' === $label ) : ?>
    			<span><?php esc_html_e( 'Posted by', 'woodmart' ); ?></span>
    		<?php endif; ?>
    
    		<?php if ( $avatar && $size ) : ?>
    			<?php echo get_avatar( get_the_author_meta( 'ID' ), $size, '', 'author-avatar' ); ?>
    		<?php endif; ?>
    
    		<?php if ( $author_name ) : ?>
    			<a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" class="author" rel="author"><?php echo get_the_author(); ?></a>
    		<?php endif; ?>
    		<?php
    	}
    }

    So I redefined the function as follows:

    if ( ! function_exists( 'woodmart_post_meta_author' ) ) {
        function woodmart_post_meta_author( $avatar = true, $label = 'short', $author_name = true, $size = 18 ) {
            if ( 'short' === $label ) {
                echo '<span>' . esc_html__( 'By', 'woodmart' ) . '</span>';
            } elseif ( 'long' === $label ) {
                echo '<span>' . esc_html__( 'Posted by', 'woodmart' ) . '</span>';
            }
    
            if ( $avatar && $size ) {
                echo get_avatar( get_the_author_meta( 'ID' ), $size, '', 'author-avatar' );
            }
    
            if ( $author_name ) {
                // Display the author's name WITHOUT a link
                echo '<span class="author">' . esc_html( get_the_author() ) . '</span>';
            }
        }
    }

    Then I added this code to the functions.php file of the Woodmart Child theme, and it worked.

    I hope the theme developer will add this option in Theme Settings → Blog → Single Post in the next update.

    #677114

    Hello,

    Sounds great that you have found the issue.

    Sorry but Additional code customizations in theme files are out of our theme support scope.

    If you want this feature, you can create a future request here – https://woodmart.canny.io/feature-requests so our developers can take it into account.

    Best Regards

Viewing 4 posts - 1 through 4 (of 4 total)