Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End [Solved] WordPress the_author_link Title Attribute

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #28371
    blue642
    Member

    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…)

    #72379
    Chris Coyier
    Keymaster

    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.

    #72384

    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 :-(

    #72409
    blue642
    Member

    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)

    #72414

    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.

    #72444
    blue642
    Member

    totally rocking the new fix… thanks so much!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Back End’ is closed to new topics and replies.