Wordpress and Webdesign Forum go41 » WordPress Code Snippets

  1. adamwork
    Member

    Similar to the way you can select which version of single.php appears, depending on the category, is there anyway to select a different author.php, depending on the author ID?

    Was thinking about using something similar to this, but adapting for author and author id...

    <?php
    $post = $wp_query->post;
    if ( in_category('X') ) {
    include(TEMPLATEPATH . '/single-b.php');
    } else {
    include(TEMPLATEPATH . '/single-a.php');
    }
    ?>

    any thoughts of how I could adapt this?

    cheers
    adam

    Posted 1 year ago #
  2. it's easier, similar to category-4.php you can use:
    author-{id}.php - If the author's ID were 4, WordPress would look for author-4.php

    see here:
    http://codex.wordpress.org/Author_Templates

    Posted 1 year ago #
  3. adamwork
    Member

    Hi joern

    thanks for getting back, i'm slightly confused though.

    What should I put in my main author.php? Currently I have:

    <?php
    if(isset($_GET['author_name'])) :
    $curauth = get_userdatabylogin($author_name);
    else :
    $curauth = get_userdata(intval($author));
    endif;
    ?>

    <?php if (have_posts()) : ?>

    <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>

    Posted 1 year ago #
  4. adamwork
    Member

    Sorry Joern, I've just re-read and think I understand now!! I basically just need to create different author.php files and call them:

    author-4.php and author-5.php etc etc...

    Posted 1 year ago #
  5. right, no switch required!

    just try it with any author ID, a copy of your original author.php and something changed to see which file wordpress takes.

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

Join us! or log in (lost password?):