Answer the question
In order to leave comments, you need to log in
How to make posts from a custom type can be put instead of the main page of the blog?
Hello.
Created a custom post type (function register_post_type();
). How can I make these posts can be put instead of the main page through the wp settings. By default, only "pages" can be selected there.
Answer the question
In order to leave comments, you need to log in
Through the settings, as far as I know, no way. However, this is easily done through code:
function t260557_cpt_on_home( $query ) {
if( $query->is_home() && $query->is_main_query() ) {
$query->set( 'post_type', 'ВАШ_POST_TYPE' );
}
}
add_action( 'pre_get_posts', 't260557_cpt_on_home' );
$query->is_home()
need to use $query->is_front_page()
. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question