Archived

This topic is now archived and is closed to further replies.

  • 0

Resolved Custom Post Types On Authors Archive Page


Question

Posted · Report post

I m trying to include custom post types on author archive page by this function


function custom_post_author_archive($query) {

if ($query->is_author)

	 $query->set( 'post_type', array('skaterstatus', 'post') );

remove_action( 'pre_get_posts', 'custom_post_author_archive' );

}

add_action('pre_get_posts', 'custom_post_author_archive');

but i get fatal error
Fatal error: Cannot redeclare custom_post_author_archive()[/code]

It used to work with earlier version of wordpress? pagelines?

How can i fix this function?

THANKS

Share this post


Link to post
Share on other sites

5 answers to this question

Posted · Report post

OK, have just found a working solution and i post it for the comunity


function custom_post_author_archive($query) {

if ($query->is_author)

	 $query->set( 'post_type', array('artykuly', 'post') );

remove_action( 'pre_get_posts', 'custom_post_author_archive' );

}

add_action('pre_get_posts', 'custom_post_author_archive');

Hope it make sense.

Share this post


Link to post
Share on other sites

Posted · Report post

Thanks for posting the resolution :)

Share this post


Link to post
Share on other sites

Posted · Report post

The topic was marked as resolved.

Share this post


Link to post
Share on other sites

Posted · Report post

Cannot redeclare means you have the function declared twice or more.

Share this post


Link to post
Share on other sites