WordPress.org

Ready to get started?Download WordPress

Forums

Pinboard
Display custom post type on home page (5 posts)

  1. courtneynutter
    Member
    Posted 10 months 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
    Member
    Posted 10 months 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
    Member
    Posted 1 month 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
    Member
    Posted 1 month 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
    Member
    Posted 1 month 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.

Reply

You must log in to post.

About this Theme

About this Topic

Tags

No tags yet.