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".

7
  • Is the file name authors.php (note plural) or author.php (note singular)? Commented Apr 22, 2014 at 17:45
  • oh sorry is author.php
    – seravifer9
    Commented Apr 22, 2014 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? Commented Apr 22, 2014 at 17:58
  • Have a look at pre_get_posts and is_author(), and see if you can come up with a starting point. Commented Apr 22, 2014 at 18:07
  • 1
    Your question should not depend on a third party service. Please add your relevant code inline here.
    – s_ha_dum
    Commented Apr 22, 2014 at 18:59

1 Answer 1

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 and acknowledge you have read our privacy policy.

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