Grow your CSS skills. Land your dream job.

[Solved] WordPress the_author_link Title Attribute

  • # March 13, 2010 at 2:11 pm

    Hello,

    I am currently customizing a theme for WordPress which you can see here http://tests.dingledoodle.com/snb/
    (no styling, just getting it to generate the content the way I want right now. I’m building it off of the blank theme from Digging into WordPress.)

    The problem I have run into is that I am using the_author_link tag to generate a link to the author’s bio page (which is a child-page of the "About the Band" page. The title attribute that is auto-generated is simply "Visit (author_name_here)’s website" I need to change that to "Learn more about (author_name_here)"

    I know I could search and replace the attribute via jQuery, but is their a WordPress way to do this? or should I be using a different technique for this? I know that the_author_posts may be a workaround, but having it link to a child page of the bio section for individual bio’s has it’s advantages….

    (the about page, also has links to each member’s page as well…)

    # March 14, 2010 at 3:13 pm

    There is almost certainly a way to change it, but these things are always just outside my current abilities I feel like. The answer is going to lay in finding out which function produces that title text output, then in your functions.php file writing a custom function which takes that as a parameter and outputs your different customized text. Then you use WordPress’ add_filter() function to attach the original function and your function. The big question is, what is the original function called? No idea.

    # March 14, 2010 at 6:10 pm

    Sometimes it’s easier to just dig into the source code ;-)

    Add the following to your functions.php and change "Visit %s’s website" to whatever you desire (%s is replaced by the author name).

    Code:
    function the_author_link() {
    if ( get_the_author_meta(‘url’) ) {
    echo ‘‘ . get_the_author() . ‘‘;
    } else {
    the_author();
    }
    }

    NB. Unfortunately there are no filters to hook into in this function :-(

    # March 15, 2010 at 10:45 am

    hmm…

    I was going to say, that I have a fear of messing with the core code in fear that I will screw things up…
    Well, I applied the code you supplied Dave (only changing the word website to bio…)

    Now my site is gone, upon updating it led me back to a blank white page, and then viewing the site itself is the same…

    anyway to fix this? or is it an uninstall re-install issue at this point?

    Also, Chris, thanks for the reply on how I might approach this, I am under the assumption now that maybe using a filter is still possible? I am researching the add_filter function, because this is entirely new to me…

    EDIT: wait a minute… coming out of "panic mode" and now into, "let’s solve this logically mode"

    I downloaded the file and removed the function that Dave supplied and saved/uploaded it, and my site is back…

    So anyone know what the problem with the supplied code is?(if there is one) and is it still possible to hook into this with a filter? (I haven’t wrapped my head around working with add_filter yet)

    # March 15, 2010 at 2:08 pm

    Ah I fear I have led you slightly astray here. I meant to change the function name – you can’t have the same name as a core function for obvious reasons, and the results you experienced.

    You can, however have a different named function that does a similar thing without any bad side effects. So if you call the function the_author_bio_link and change your theme correspondingly you should be back up and running.

    Sorry for missing this rather obvious mistake.

    # March 15, 2010 at 10:48 pm

    totally rocking the new fix… thanks so much!

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

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".