• Resolved nickaster

    (@nickaster)


    Howdy.

    I have certain authors who have their own websites and so on and would rather their name link to their personal page rather than the default WordPress author archive.

    Is there a way to give them the option?

    The only way i can think of now is to hack the template with a redirect if the Author = XYZ

Viewing 10 replies - 1 through 10 (of 10 total)
  • You template file(whichever shows the author link), probably has the following..

    <?php the_author_posts_link() ?>

    http://codex.wordpress.org/Template_Tags/the_author_posts_link

    Switching it to the URL in the author’s profile is case of switching to another function.

    <?php the_author_link() ?>

    http://codex.wordpress.org/Template_Tags/the_author_link

    How you conditionalise which is used is up to you…

    Thread Starter nickaster

    (@nickaster)

    Excellent, thanks! Okay, how do I make it so the default is the first one, and ONLY if there’s another link specified does it choose the later? (I don’t know chicken about PHP)

    What theme are you using, is it one available to download?

    In theory, simple conditional statement, check if author has defined a website url, if so display it, else use the regualr style link, ie. posts link.

    Thread Starter nickaster

    (@nickaster)

    Thanks! …. so yeah…. theme is custom, why does it matter? I have no idea how to write a statement like that. You got any clue?

    That’s why i asked about the theme, i can only guess how many files and how many calls there are to that function in your given theme without being able to see the files.

    Let me go test some code, if i can work out the conditional statement for you, then all you’d need do in theory is update each file where the relevant author code currently exists.

    Be back shortly..

    Thread Starter nickaster

    (@nickaster)

    Thanks! I’m guessing the theme isn’t important in this case. I can find the places where it happens, so I can get in there and replace it no problem. I do wish there were a way to search across template code, however.

    If you keep files locally then all you need do is use an editor that can search within files(such as Notepad++ , takes less then a minute to find all occurances of a string or piece of text, or whatever).

    In regard to the conditional code, find each occurance of this..

    <?php the_author_posts_link(); ?>

    ..and replace with..

    <?php $author_url = get_the_author_url(); if( $author_url == '' ) the_author_posts_link(); else the_author_link(); ?>

    Tested the code as working.. 🙂

    Thread Starter nickaster

    (@nickaster)

    Rock solid. Works like a charm. THank you!

    You’re welcome.. 🙂

    So my template index file does not have this code ‘<?php the_author_posts_link() ?>’ to replace. I did however insert this code into my sidebar php file where I have Authors located:

    ‘<?php $author_url = get_the_author_url(); if( $author_url == ” ) the_author_posts_link(); else the_author_link(); ?>’

    It is showing me under Authors section, I’m an admin, and it is linking to my URL I inserted under my profile settings. But two things did not translate over when I inserted the code:

    1. It’s only displaying me under admin in the sidebar. How do I get it to show authors like the code represents? I have jdoe at the top of the blog as you can see, he’s an author.
    2. All my sidenav elements have a blue color css tag for UL, LI tags. And the Author link does not. They are the same tags that the CSS should of recognized. How do I make them blue?

    Site:
    http://visionarynoise.com/

    Thank you

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Special Author Links to Outside Page?’ is closed to new replies.