0

I'm trying to show all post made ​​by the author.

Code author.php

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php if( get_post_type() == 'post' ) {?>

<?php } if( get_post_type() == 'post-type' ) {?>

<?php } else; endwhile;?>
<?php endif; ?>

But just shows the post_type "post".

  • Is the file name authors.php (note plural) or author.php (note singular)? – Chip Bennett Apr 22 '14 at 17:45
  • oh sorry is author.php – seravifer9 Apr 22 '14 at 17:46
  • 1
    The author.php template file by default only shows posts of the post post-type. What have you done to filter the main query to display posts of other post-types? – Chip Bennett Apr 22 '14 at 17:58
  • Have a look at pre_get_posts and is_author(), and see if you can come up with a starting point. – Chip Bennett Apr 22 '14 at 18:07
  • 1
    Your question should not depend on a third party service. Please add your relevant code inline here. – s_ha_dum Apr 22 '14 at 18:59
1

You need to add this code to the file functions.php.

function custom_post_author_archive($query) {
    if ($query->is_author)
        $query->set( 'post_type', array('post-type', 'post') );
    remove_action( 'pre_get_posts', 'custom_post_author_archive' );
}
add_action('pre_get_posts', 'custom_post_author_archive');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.