How to set a custom post type as home page and set post page to regular post?

I am trying to create a child theme where I have created a custom post type i.e “art”. I want to display all CPT posts to the homepage with pagination and the regular post to the post page.

Currently, I set Your latest posts reading settings and add an action that will show my all custom post type at home page.

add_action( 'pre_get_posts', 'add_cpt_to_homepage' );

function add_cpt_to_homepage( $query ) {
    if ( is_home() && $query->is_main_query() )
        $query->set( 'post_type', array( 'art' ) );
    return $query;
}

But my question is, is there any way to show my regular post on a different page?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Yes, there is a way to show your regular posts on a different page.

  1. Create a new page template
  2. Include a new WP_Query using post as the post-type. Example
  3. On the backend, create the page you want to use to display your posts
  4. In the options, select your new page template for the page
  5. Your posts should appear on the new page


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x