WordPress.org

Support

Support » Themes and Templates » Display custom post type on home page

Display custom post type on home page

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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.

    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 */
    }
    }

    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

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display custom post type on home page’ is closed to new replies.