WordPress.org

Forums

Types - Custom Fields and Custom Post Types Management
No Custom Posts on Author summary p (5 posts)

  1. mdlepage
    Member
    Posted 2 years ago #

    Hi,

    There are no custom posts showing on the Author's summary page, even though the author created a custom post.

    Now I had to add this code to my functions.php to get custom posts to show in the main index blog feed
    // add Articles custom post type to home page feed

    add_filter( 'pre_get_posts', 'my_get_posts' );

    function my_get_posts( $query ) {

    if ( ( is_home() && false == $query->query_vars['suppress_filters'] ) || is_feed() )
    $query->set( 'post_type', array( 'post', 'article' ) );

    return $query;
    }

    Is there something similar I have to do to have custom post show up on the author's page?

    Thanks. I do really like this module btw.

    M

    http://wordpress.org/extend/plugins/types/

  2. AmirHelzer
    Member
    Plugin Author

    Posted 2 years ago #

    This really depends on your theme. If the theme is not loading these custom posts, they will not show.

  3. mdlepage
    Member
    Posted 2 years ago #

    Amir,

    There must be a few lines of code I can add to functions.php to get this to work. The custom post types work everywhere else on my site, except on the author pages. Any help would be really appreciated. Can you at least point me in the right direction?

    Thanks,
    Michael

  4. mdlepage
    Member
    Posted 2 years ago #

    Ok, googled and found a solution. Amir, I might suggest adding it to your FAQ or other documentation.

    To fix the authors page to show custom posts add the following code to your functions.php file. Note the array is used to display multiple post types. If you need to display only one type, remove the array.

    function custom_post_author_archive( &$query )
    {
        if ( $query->is_author )
            $query->set( 'post_type', array( 'post', 'your-custom-type-here' ) );
        remove_action( 'pre_get_posts', 'custom_post_author_archive' ); // run once!
    }
    add_action( 'pre_get_posts', 'custom_post_author_archive' );

    Hope that helps anyone else stuck on this.

  5. AmirHelzer
    Member
    Plugin Author

    Posted 2 years ago #

    Thanks for posting the code here. I'm sure that others will find it useful as well.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags