Display custom post type on home page (5 posts)

  1. courtneynutter
    Posted 2 years ago #

    I have a custom post type called 'Boats.' I'd like the custom posts to display on the home page just like the sample Pinboard page image.

    How can I do this??

  2. hartmutnz
    Posted 2 years ago #

    Hi, first create a CATEGORY , e.g. Boats
    Then assign all posts to that category that you want to show on the Frontpage
    Then go to SETTINGS >> READING >>
    Front page displays:
    (-Your latest posts)
    PICK THIS >>> -A static page (select below)
    ...select the Category from the dropdown menu.. done! SAVE the settings.

  3. Jens M Eichkorn
    Posted 2 years ago #

    I think he was talking about custom post types so that's not the solution.

    I know it's late but maybe it helps in the future. What you want is a funktion in the function.php of your theme (at the end):

    add_action( 'pre_get_posts', 'include_yourCustomPostType_in_home' );

    function include_events_in_home( $query ) {

    if ( ! is_admin() && $query->is_main_query() && $query->is_home() ) {
    $query->set( 'post_type', array( 'post', 'yourCustomPostType' ) ); /* Set your Custom Post Type Name instead of yourCustomPostType */

  4. hartmutnz
    Posted 2 years ago #

    Thanks Jens, good work. It is possible of course, but then you would also want a "child theme" to make sure that your customization stays intact. So yes, if someone wants to go that far. My solution to create a category and assign it to the homepage is easy for the beginners and works well. One needs to organize the posts in some way anyway.. Cheers, Groggo

  5. Jens M Eichkorn
    Posted 2 years ago #

    The problem is, that custom post types won't be displayed on the home page no matter what category they have.

    So he still need's this work around.

    And yes - a child theme would be recommended, in case he doesn't want to loose changes after updating. So I put it in a child themes functions.php.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic


No tags yet.