[wp-hackers] profiles for authors with no posts

Steve Taylor steve at sltaylor.co.uk
Fri Jan 21 19:44:42 UTC 2011


Thanks, Philip, works great.

I was thinking about intercepting the 404 - I definitely need to get
in the habit of tweaking the default query more!

cheers,

Steve

On 21 January 2011 18:51, Philip M. Hofer (Frumph) <philip at frumph.net> wrote:
> I just add the other post types to the pre_get_posts filter $wp_query->set
> with a conditional for those pages
>
> the if (is_author()) will denote that it's an author page
>
>  add_filter('pre_get_posts', 'mytheme_add_post_type_to_query');
>
>  function 'mytheme_add_post_type_to_query($query) {
>  if ($query->is_author) {
>   $query->set('post_type', array('post',
> 'customposttype','customposttype'));
>  }
>  return $query;
>  }
>
> writing this from memory so not sure if it will work, but maybe it's a lead
> in for you to look into
>
>
>
> ----- Original Message ----- From: "Steve Taylor" <steve at sltaylor.co.uk>
> To: "wp-hackers" <wp-hackers at lists.automattic.com>
> Sent: Friday, January 21, 2011 10:35 AM
> Subject: [wp-hackers] profiles for authors with no posts
>
>
>> Hi folks,
>>
>> I'm working on a theme for an online academic journal. Because it's
>> structured based on articles grouped by issue, I'm using a custom post
>> type for articles, and a custom field to assign them to an issue.
>>
>> The problem is that by default the /author/authors-name/ permalink
>> returns a 404 if they have no posts - presumably this is purely based
>> on posts of the post_type "post"!
>>
>> I can think of a few ways round this, but before I dive in, I thought
>> I'd ask - what's the most elegant way anyone here's achieved this?
>>
>> Furthermore, is this an issue worth raising? I might be missing a Trac
>> ticket, but a quick search found nothing. Surely author profiles
>> should accommodate custom post types? What about pages even?
>>
>> cheers,
>>
>> Steve
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list