how to creat a coustom page template for a category posts
-
i want to creat a coustom page template where i wana show a single category posts for example category slug “news” posts there . i want a coustom page same like home page but only want specific category posts on that page . please help
i have created a coustom template with the help of wp_query everything works fine but some problem with page numbring and page thumnails .
by the way i have copied all index.php and creat a coustome page
here is my code`<?php /* Template Name: Custompage */ get_header(); ?>
<?php
/* Blog Options */
$post_template = xmag_blog_post_template();
?><div id=”primary” class=”content-area”>
<main id=”main” class=”site-main” role=”main”><?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<div class=”posts-loop”>
<?php
global $paged; global $wp_query;
$temp = $wp_query; $wp_query= null; $wp_query = new WP_Query();
$wp_query->query(‘showposts=10&cat=13′.’&paged=’.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
?><?php
/* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( ‘template-parts/’ . $post_template );
?>
<?php endwhile;?>
</div><!– / .posts-loop –>
<?php the_posts_pagination( array(
‘mid_size’ => 2,
‘prev_text’ => esc_html( ‘←’ ),
‘next_text’ => esc_html( ‘→’ ),
) ); ?><?php $wp_query = null; $wp_query = $temp;?>
<?php else : ?>
<?php get_template_part( ‘template-parts/content’, ‘none’ ); ?>
<?php endif; ?>
</main><!– #main –>
</div><!– #primary –><?php get_sidebar(); ?>
<?php get_footer(); ?>but thumbnails not showing correctly . still waiting for your help
- The topic ‘how to creat a coustom page template for a category posts’ is closed to new replies.