• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Customizing the Author Box Title is generating some weird results

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Customizing the Author Box Title is generating some weird results

This topic is: not resolved
  • This topic has 8 replies, 2 voices, and was last updated 10 years, 9 months ago by Ronald.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • September 20, 2015 at 3:49 pm #166169
    Ronald
    Member

    So I wanted the Author Box Title to link to the author's archive page when on a single post, but not when the Author Box is used on the Archive Page.

    I added the following code using the snippets here: http://my.studiopress.com/snippets/author-box/#modify-title
    and the WordPress codex here: https://codex.wordpress.org/Function_Reference/the_author_posts_link

    //* Customize the author box title
    add_filter( 'genesis_author_box_title', 'custom_author_box_title' );
    function custom_author_box_title() {
        if ( is_single() ) {
    	return '<strong>About '.the_author_posts_link().'</strong>';
    } else {
        return '<strong>About '.the_author().'</strong>';   
        }
    }

    And these are the results I am getting using that code.

    On the single post
    Image of Author Box on a single post

    On the Archive Page:
    Image of Author Box on the Archive Page

    Both seem to place the author information separated above the actual Author Box. the_author_posts_link() does not display anything in the actual Author Box, but the_author() shows in both places.

    I have no idea what could be causing this, Any ideas?

    September 20, 2015 at 6:19 pm #166172
    Victor Font
    Moderator

    Both the_author_posts_link() and the_author() functions must be used in the loop.They won't work anywhere else. What you want to use is: $author_link = get_author_posts_url( get_the_author_meta( 'ID' ) ); and $author = get_the_author();.

    Here is your function rewritten:

    //* Customize the author box title
    add_filter( 'genesis_author_box_title', 'custom_author_box_title' );
    function custom_author_box_title() {
        if ( is_single('post') ) {
            $author_link  = get_author_posts_url( get_the_author_meta( 'ID' ) );
    	return '<strong>About ' . $author_link . '</strong>';
    } else {
       $author = get_the_author();
        return '<strong>About ' . $author . '</strong>';   
        }
    }

    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    September 21, 2015 at 8:59 am #166214
    Victor Font
    Moderator

    There's an error in the code I gave you above. I hadn't tested it in my local dev site before I posted and it bothered me a little because I didn't know if it would work or not. It doesn't work. I refactored it this morning and here is the version that will give you what you want. Sorry about the confusion.

    //* Customize the author box title
    add_filter( 'genesis_author_box_title', 'vmf_custom_author_box_title' );
    function vmf_custom_author_box_title() {
    	if ( is_single() ) {
    		$author = get_the_author();
    		$author_link  = '<a href="' . get_author_posts_url( get_the_author_meta( 'ID' ) ) . '">' . $author . '</a>';
    		return '<strong>About ' . $author_link . '</strong>';
    	} else {
    		$author = get_the_author();
    		return '<strong>About ' . $author . '</strong>';
    	}
    }

    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    September 21, 2015 at 10:53 am #166222
    Victor Font
    Moderator

    There's one concern I'd like to add about your approach. WordPress uses the user_nicename field as the URL for author archive pages. The user_nicename holds the same value as the user_login. There's no way to change this in the admin area. By using author archive pages, you are exposing user login ids to the world. There's no easy way to fix this. However, here's an article that explains how to change the user_nicename with PHPMyAdmin: http://premium.wpmudev.org/blog/change-admin-username/.

    As an FYI, I would not use this code on any of my sites because of this security concern.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    September 21, 2015 at 7:58 pm #166281
    Ronald
    Member

    Oh wow thank you Victor, I did not even know about the security issue.

    Thank you for all of your input, and if thats the case, I might have to re-consider not using the Author Archive Pages.

    September 21, 2015 at 8:02 pm #166283
    Ronald
    Member

    Quick question. If I did change the user_nicename in phpmyadmin, would that solve the security issue? Because, that would be an easy fix and I would still get the functionality I want.

    If that doesn't actually fix the security issue, then I will probably just get rid of the author box. This is going to be a multi-author blog so it would be easier to use the genesis author box, then to hand-code a single "about the author" block that I have done in most of my other sites.

    September 21, 2015 at 8:10 pm #166286
    Ronald
    Member

    Btw, thank you for the code-snippet! it works perfectly...just got to figure out if I am actually going to use it now!

    September 21, 2015 at 10:03 pm #166292
    Victor Font
    Moderator

    Ronald, changing user_nicename would change the security issue. Keep in mind that user_nicename is used as a slug. It cannot contain spaces. You'll just have to make the change for every author.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    September 21, 2015 at 10:13 pm #166293
    Ronald
    Member

    Ah wonderful, well there is only going to be about 4-5 authors so this is a great work-around. Thank you again for the code-snippet and your security advice!

  • Author
    Posts
Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble