Opened 13 years ago
Last modified 6 years ago
#18791 new enhancement
Add custom post type support for Author Template functions
Reported by: | sirzooro | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.2.1 |
Component: | Users | Keywords: | needs-unit-tests needs-patch |
Focuses: | template | Cc: |
Description
Functions defined in wp-includes/author-template.php
assumes that post type == post. It will be good to enhance them so they will be able to work with specified post type.
At first sight following functions will need update:
get_the_author_link() the_author_link() get_the_author_posts() the_author_posts() the_author_posts_link() get_author_posts_url() wp_list_authors()
I suspect there will be other updates needed, to support new post_type
argument added to author's url.
Attachments (3)
Change History (18)
#2
@
13 years ago
- Keywords dev-feedback added
WordPress already has WP_User
class - probably it would be better to add new methods to it instead of creating a WP_Author
class.
I wonder if it is possible to create posts without assigning any user as author (anonymous posting) - if yes, WP_Author
class would be better solution.
#3
@
11 years ago
- Component changed from Template to Users
- Focuses template added
- Keywords dev-feedback removed
#4
@
11 years ago
Looks like get_the_author_posts()
, the_author_posts()
, and wp_list_authors()
are the only ones that are still limited to just posts.
#6
follow-up:
↓ 7
@
11 years ago
I think 18791.patch takes care of it.
#7
in reply to:
↑ 6
;
follow-up:
↓ 8
@
11 years ago
Replying to mordauk:
I think 18791.patch takes care of it.
I may be misreading this one, but it looks like the patch only supports one post type being passed.
#8
in reply to:
↑ 7
@
11 years ago
Replying to norcross:
Replying to mordauk:
I think 18791.patch takes care of it.
I may be misreading this one, but it looks like the patch only supports one post type being passed.
Updated patch attached to address this.
#9
@
11 years ago
- Keywords has-patch added; needs-patch removed
- Milestone changed from Awaiting Review to 4.0
While I like the idea of someday being able to add multi support for post types here, I think it would be best to tackle that separately. Switching to multiple post types would just send us down a rabbit hole in several spots, not limited to the cap checks in get_posts_by_author_sql()
.
In 18791.2.patch, I've removed the multiple post types support, cleaned up the logic and added the requisite inline docs updates.
I left in the change to is_multi_author()
where the post_type
condition was removed, though I'm a little dubious of the effect of that, especially since we don't currently have any kind of content definition for what does or doesn't have "authors".
#10
follow-up:
↓ 11
@
11 years ago
I think is_multi_author() should be left alone entirely.
Not sure I see why get_posts_by_author_sql() needs to change at all, either. The sanitization/preparation in get_posts_by_author_sql() looks wrong. A unit test would catch this. (Needs unit tests.) The other instance of $post_type_where has similar issues.
#11
in reply to:
↑ 10
@
11 years ago
Replying to nacin:
I think is_multi_author() should be left alone entirely.
Not sure I see why get_posts_by_author_sql() needs to change at all, either. The sanitization/preparation in get_posts_by_author_sql() looks wrong. A unit test would catch this. (Needs unit tests.) The other instance of $post_type_where has similar issues.
If not adding support for multiple post types, I think you're right in that get_posts_by_author_sql() doesn't need changed at all.
I'd disagree about is_multi_author() though. For sites that use multiple public post types, it would be expected for is_multi_author() to properly detect when there are multiple authors on the site.
+1.
Would it not make sense to consider creating a
WP_Author
class too?