Jump to content
jankowalski

Custom Post Types On Authors Archive Page

Recommended Posts

jankowalski    3
jankowalski

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
Simon    247
Simon

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

Share this post


Link to post
Share on other sites
jankowalski    3
jankowalski

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
James B    436
James B

Thanks for posting the resolution :)


Kindly search the forum and read the documentation before posting. It will help you resolve many issues.

For CSS help be sure to check out W3Schools first and be sure to download FireBug for FireFox for troubleshooting.

James B

Share this post


Link to post
Share on other sites
James B    436
James B

The topic was marked as resolved.


Kindly search the forum and read the documentation before posting. It will help you resolve many issues.

For CSS help be sure to check out W3Schools first and be sure to download FireBug for FireFox for troubleshooting.

James B

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Similar Content

    • art23130
      By art23130+
      I have uploaded a file shoing missing sections for Custom Post Type
      It is OK for categories and tags but not for a single post types. 
      This is the link. 
      https://www.geoinformation.com/geocode_library/10-10570-rsg-2016-003/
      Any idea?
      thanks 
      Binder1.pdf
    • PeriniNero
      By PeriniNero+
      We are building a Custom Post Type with Custom Fields and Custom Taxonomies.
      The only thing we dont understand is how to embed the Custom Fields including header tags and stuff in the Postloop (now we use a text-box below the postloop section but also SEO wise this is not best pratice).
      So we thought to copy the dms Postloop section to our child theme and rename this, to add an extra Postloop section to our theme. Is this the way?
      What exactly to adjust in those 3 files class.posts.php, section.php and style.less (at this point we know how to change the thumb LOL) and where to add the Custom Fields shortcodes?
      Thanks.
    • Audun MB
      By Audun MB+
      I'm using plugins such as Events Manager and WP Glossary. Basically I need to edit the meta information and the breadcrumb for the custom post types Event and Term. The plugins instruct me to add a single-event.php and single-glossary.php in my (child) theme.
      What should I use as a basis for these files? Can I use the templates in the Framework main theme as a basis (tpl-a.php)? Or should I use the whole page.php file?
       
    • ketri
      By ketri
      Hello,

      When I select a page template for a custom post type page, it also selects the same template for the children of this custom post type. 
      I want to have my custom post type template as a heavily customized loop that I've developed myself, and the children (they are articles) as a completely another template.
       
      Is there a function that would allow me to select different templates for them on DMS?

      Thank you very much in advance.
    • dawsonbarber
      By dawsonbarber+
      Hi Enrique
       
      I want to add a Starbar to a Custom Post Type.
       
      I've tried to simply copy/paste the full section code from the source code, but the animation doesn't happen.
       
      Any idea on what I'm missing/doing wrong?

      Cheers
       
      Dawson
×