pagination – How can I paginate on the frontpage?
Question
The block of code in the theme’s function.php
below returns a post on the frontpage. Although there are additional posts, it doesn’t return the pagination.
function mg_front_page($query){
if ( $query->is_main_query() && get_option( 'show_on_front' ) === 'page' ) {
if( $query->get("page_id") == get_option("page_on_front") ) {
$front_page_post_type = get_post_type( $query->get("page_id") );
$query->set( 'post_type', $front_page_post_type );
$query->is_page = 0;
$query->is_singular = 0;
$query->is_post_type_archive = 1;
$query->is_archive = 1;
}
}
}
add_action("pre_get_posts", "mg_front_page");
0
1 year
2022-02-12T21:07:16-05:00
2022-02-12T21:07:16-05:00 0 Answers
0 views
0
Leave an answer