• Tomica

    (@digitalnacarolija)


    I have a static page titled after a blog author, David. It’s using a template named ‘page-david.php’. I want to make that page (and that template) be the author archive page, i.e. when a visitor clicks the author’s archive link, he should be directed to the ‘David’ page and see the ‘page-david.php’ template. Is that possible?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Frumph

    (@frumph)

    Is there a reason you are not using author.php ? i.e. author pages in your theme and want it as pages instead?

    Thread Starter Tomica

    (@digitalnacarolija)

    I’m not sure, but couldn’t think of any other way to achieve what I want. There are several Custom Post Types on my website. All the content is being created by several authors. Hence, every author has content of multiple custom types. On the other side, I need to have an Author Page for each author, where I would have a static introductory text (needs to be editable from the Dashboard), and archives of only some post types, while some others shouldn’t be displayed. Now, I already have a page template for each author. If I try to use that template as an author-$name.php template, a blog post is displayed instad of the introductory text. I simply thought this would be the simplest solution for my situation, if only it was possible – to set an already existing page to act as an author archive page.

    Frumph

    (@frumph)

    well, you can customize the author.php to have any loop you want inside of it, posts custom post types or whatever you want, it’s basically a template file…

    Which, really would be a heck of a lot simpler. The information you get from each author can be edited in the authors preferences in the wp-admin in the users panel and you can just grab that information directly.

    Here is my author.php from my theme: https://github.com/Frumph/easel/blob/master/author.php you could use for reference if you wanted, notice that you can ‘add’ any loop you want to it since it’s just a template, like you would do with the page-author .. but this is a single page that encompasses everyone, don’t really need to add individual ones for each author imo. not to mention clicking their name on links goes to the author pages already so no extra coding…

    just a thought.

    Frumph

    (@frumph)

    the: <?php echo $curauth->description; ?> comes from the description each author can set in their userinfo in the wp-admin

    Thread Starter Tomica

    (@digitalnacarolija)

    Frumph thank you so much, I’m sure this will help a lot. Unfortunately, I can’t use the Author Description as the introductory text, since a) the introductory text needs rich formatting, b) Author description is already used on some other places. I’m not sure how to solve this problem then, because the current Author Page content does not show when I use the author.php template. By the way, yes, your advice to only use author.php is valid. Thank you.

    Frumph

    (@frumph)

    okay let’s go a different route and use the pages-<authorname>.php then

    let me show you how to do that

    This is a common use of the authors link in your posts info:

    $post_author = "<span class=\"post-author\">".__('by','easel')." <a href=\"".get_author_posts_url( $authordata->ID, $authordata->user_nicename )."\">".get_the_author()."</a></span>\r\n";

    basically, creating your own link to the pages in question, using the function get_author_posts_url .. instead of get_author_posts_url you can just create your own markup for the link directing to the correct location.. since $authordata is global for the post

    you add global $authordata; to the top of the place where your posts code

    then you can use $authordata->user_nicename as the pagename

    <a href="/authors/<?php echo $authordata->user_nicename; ?>">

    sort of thing which will be the link to the page for the author, but you need to adjust your posts section of how it displays the current post author link and modify it so it links to that page in question

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Turn a static page into an author archive’ is closed to new replies.