Display a single category in blog section
I have been struggling with a problem, I have a webpage running on WordPress, most of the things work as expected, except one: in the blog section page (the one that is configured in settings/reading - Posts page), all posts are shown. I have a specific category that should be presented there, but I don't know how to alter the loop to work as expected. Here´s the code of the index page:
?php
$class_archive = '';
$is_grid_layout = get_theme_mod( 'thim_front_page_cate_display_layout', false );
$layout_type = $is_grid_layout ? 'grid' : '';
if ( $layout_type == 'grid' ) {
$class_archive = ' blog-switch-layout blog-list';
global $post, $wp_query;
if ( is_category() ) {
$total = get_queried_object();
$total = $total-count;
} elseif ( ! empty( $_REQUEST['s'] ) ) {
$total = $wp_query-found_posts;
} else {
$total = wp_count_posts( 'post' );
$total = $total-publish;
}
if ( $total == 0 ) {
echo 'p class=message message-error' . esc_html__( 'There are no available posts!', 'eduma' ) . '/p';
return;
} elseif ( $total == 1 ) {
$index = esc_html__( 'Showing only one result', 'eduma' );
} else {
$courses_per_page = absint( get_option( 'posts_per_page' ) );
$paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
$from = 1 + ( $paged - 1 ) * $courses_per_page;
$to = ( $paged * $courses_per_page $total ) ? $total : $paged * $courses_per_page;
if ( $from == $to ) {
$index = sprintf(
esc_html__( 'Showing last post of %s results', 'eduma' ),
$total
);
} else {
$index = sprintf(
esc_html__( 'Showing %s-%s of %s results', 'eduma' ),
$from,
$to,
$total
);
}
}
}
I've added:
$args = array(
cat = 200
);
// Custom query.
$wp_query = new WP_Query( $args );
Without any success.
Thanks in advance for your help.