Skip to main content
deleted 903 characters in body
Source Link
Godwin
  • 103
  • 3

The site I'm currently working on includes profile pages for each author plus a method to search for posts by a specific author. So we would have a page at /author/author-name/ that only displays a list of posts by that author and a page at something like /author/author-name/profile/ that shows extended user info but no posts.

By default Wordpress includes an author.php template that shows some basic user info and recent posts by the author. This is found at /author/author-name/. When looking for recommended ways to build a user profile, everything I have found recommends altering this file and using the same URL, however we would like to use both.

The only way I can think of achieving this would be to allow the page to take a parameter so that /author/author-name/?profile=1, rewrite it in .htaccess so that it appears as /author/author-name/profile/. Then alter author.php to check for this parameter and use a separate template. I would like to avoid methods such as this and stay on the Wordpress rails as much as possible.

Are there any plugins or other Wordpress approved methods I could use to solve this problem? (We're running 3.8 by the way).

===================================

EDIT:
In case you're not familiar with add_rewrite_endpoint, here's what I came up with based on the Rarst's link.

Create a template file named author-profile.php. In your functions.php file add the following:

add_action('init', 'theme_add_author_profile_endpoint');
add_action('template_redirect', 'theme_author_profile_template_redirect');

function theme_add_author_archive_endpoint() {
    add_rewrite_endpoint('profile', EP_AUTHORS);
}

function theme_author_archive_template_redirect() {
    global $wp_query;
    if (isset($wp_query->query_vars['profile']) && is_author()) {
        include dirname( __FILE__ ).'/author-profile.php';
        exit;
    }
}

This should allow /author/author-name/ to be directed to the default author.php template while /author/author-name/profile/ will be directed to author-profile.php.

The site I'm currently working on includes profile pages for each author plus a method to search for posts by a specific author. So we would have a page at /author/author-name/ that only displays a list of posts by that author and a page at something like /author/author-name/profile/ that shows extended user info but no posts.

By default Wordpress includes an author.php template that shows some basic user info and recent posts by the author. This is found at /author/author-name/. When looking for recommended ways to build a user profile, everything I have found recommends altering this file and using the same URL, however we would like to use both.

The only way I can think of achieving this would be to allow the page to take a parameter so that /author/author-name/?profile=1, rewrite it in .htaccess so that it appears as /author/author-name/profile/. Then alter author.php to check for this parameter and use a separate template. I would like to avoid methods such as this and stay on the Wordpress rails as much as possible.

Are there any plugins or other Wordpress approved methods I could use to solve this problem? (We're running 3.8 by the way).

===================================

EDIT:
In case you're not familiar with add_rewrite_endpoint, here's what I came up with based on the Rarst's link.

Create a template file named author-profile.php. In your functions.php file add the following:

add_action('init', 'theme_add_author_profile_endpoint');
add_action('template_redirect', 'theme_author_profile_template_redirect');

function theme_add_author_archive_endpoint() {
    add_rewrite_endpoint('profile', EP_AUTHORS);
}

function theme_author_archive_template_redirect() {
    global $wp_query;
    if (isset($wp_query->query_vars['profile']) && is_author()) {
        include dirname( __FILE__ ).'/author-profile.php';
        exit;
    }
}

This should allow /author/author-name/ to be directed to the default author.php template while /author/author-name/profile/ will be directed to author-profile.php.

The site I'm currently working on includes profile pages for each author plus a method to search for posts by a specific author. So we would have a page at /author/author-name/ that only displays a list of posts by that author and a page at something like /author/author-name/profile/ that shows extended user info but no posts.

By default Wordpress includes an author.php template that shows some basic user info and recent posts by the author. This is found at /author/author-name/. When looking for recommended ways to build a user profile, everything I have found recommends altering this file and using the same URL, however we would like to use both.

The only way I can think of achieving this would be to allow the page to take a parameter so that /author/author-name/?profile=1, rewrite it in .htaccess so that it appears as /author/author-name/profile/. Then alter author.php to check for this parameter and use a separate template. I would like to avoid methods such as this and stay on the Wordpress rails as much as possible.

Are there any plugins or other Wordpress approved methods I could use to solve this problem? (We're running 3.8 by the way).

added 905 characters in body
Source Link
Godwin
  • 103
  • 3

The site I'm currently working on includes profile pages for each author plus a method to search for posts by a specific author. So we would have a page at /author/author-name/ that only displays a list of posts by that author and a page at something like /author/author-name/profile/ that shows extended user info but no posts.

By default Wordpress includes an author.php template that shows some basic user info and recent posts by the author. This is found at /author/author-name/. When looking for recommended ways to build a user profile, everything I have found recommends altering this file and using the same URL, however we would like to use both.

The only way I can think of achieving this would be to allow the page to take a parameter so that /author/author-name/?profile=1, rewrite it in .htaccess so that it appears as /author/author-name/profile/. Then alter author.php to check for this parameter and use a separate template. I would like to avoid methods such as this and stay on the Wordpress rails as much as possible.

Are there any plugins or other Wordpress approved methods I could use to solve this problem? (We're running 3.8 by the way).

===================================

EDIT:
In case you're not familiar with add_rewrite_endpoint, here's what I came up with based on the Rarst's link.

Create a template file named author-profile.php. In your functions.php file add the following:

add_action('init', 'theme_add_author_profile_endpoint');
add_action('template_redirect', 'theme_author_profile_template_redirect');

function theme_add_author_archive_endpoint() {
    add_rewrite_endpoint('profile', EP_AUTHORS);
}

function theme_author_archive_template_redirect() {
    global $wp_query;
    if (isset($wp_query->query_vars['profile']) && is_author()) {
        include dirname( __FILE__ ).'/author-profile.php';
        exit;
    }
}

This should allow /author/author-name/ to be directed to the default author.php template while /author/author-name/profile/ will be directed to author-profile.php.

The site I'm currently working on includes profile pages for each author plus a method to search for posts by a specific author. So we would have a page at /author/author-name/ that only displays a list of posts by that author and a page at something like /author/author-name/profile/ that shows extended user info but no posts.

By default Wordpress includes an author.php template that shows some basic user info and recent posts by the author. This is found at /author/author-name/. When looking for recommended ways to build a user profile, everything I have found recommends altering this file and using the same URL, however we would like to use both.

The only way I can think of achieving this would be to allow the page to take a parameter so that /author/author-name/?profile=1, rewrite it in .htaccess so that it appears as /author/author-name/profile/. Then alter author.php to check for this parameter and use a separate template. I would like to avoid methods such as this and stay on the Wordpress rails as much as possible.

Are there any plugins or other Wordpress approved methods I could use to solve this problem? (We're running 3.8 by the way).

The site I'm currently working on includes profile pages for each author plus a method to search for posts by a specific author. So we would have a page at /author/author-name/ that only displays a list of posts by that author and a page at something like /author/author-name/profile/ that shows extended user info but no posts.

By default Wordpress includes an author.php template that shows some basic user info and recent posts by the author. This is found at /author/author-name/. When looking for recommended ways to build a user profile, everything I have found recommends altering this file and using the same URL, however we would like to use both.

The only way I can think of achieving this would be to allow the page to take a parameter so that /author/author-name/?profile=1, rewrite it in .htaccess so that it appears as /author/author-name/profile/. Then alter author.php to check for this parameter and use a separate template. I would like to avoid methods such as this and stay on the Wordpress rails as much as possible.

Are there any plugins or other Wordpress approved methods I could use to solve this problem? (We're running 3.8 by the way).

===================================

EDIT:
In case you're not familiar with add_rewrite_endpoint, here's what I came up with based on the Rarst's link.

Create a template file named author-profile.php. In your functions.php file add the following:

add_action('init', 'theme_add_author_profile_endpoint');
add_action('template_redirect', 'theme_author_profile_template_redirect');

function theme_add_author_archive_endpoint() {
    add_rewrite_endpoint('profile', EP_AUTHORS);
}

function theme_author_archive_template_redirect() {
    global $wp_query;
    if (isset($wp_query->query_vars['profile']) && is_author()) {
        include dirname( __FILE__ ).'/author-profile.php';
        exit;
    }
}

This should allow /author/author-name/ to be directed to the default author.php template while /author/author-name/profile/ will be directed to author-profile.php.

Source Link
Godwin
  • 103
  • 3

Creating distinct pages for author profiles and lists of posts by author

The site I'm currently working on includes profile pages for each author plus a method to search for posts by a specific author. So we would have a page at /author/author-name/ that only displays a list of posts by that author and a page at something like /author/author-name/profile/ that shows extended user info but no posts.

By default Wordpress includes an author.php template that shows some basic user info and recent posts by the author. This is found at /author/author-name/. When looking for recommended ways to build a user profile, everything I have found recommends altering this file and using the same URL, however we would like to use both.

The only way I can think of achieving this would be to allow the page to take a parameter so that /author/author-name/?profile=1, rewrite it in .htaccess so that it appears as /author/author-name/profile/. Then alter author.php to check for this parameter and use a separate template. I would like to avoid methods such as this and stay on the Wordpress rails as much as possible.

Are there any plugins or other Wordpress approved methods I could use to solve this problem? (We're running 3.8 by the way).