Page Template for one Category

Hi there,

currently I administrate the website of my soccer club (www.tsvschlieben.de). I run the site with Wordpress and a child theme of one of the standard themes of Wordpress. I want to redesign the entire website with your Sparkling theme. I installed Wordpress and the Sparkling theme + child theme locally on my notebook the create and adjust the new layout. I created static pages for eg. the contact or impressum page. So far everything is good and it looks as I wanted it. The last step is only to create different page templates to show diffenrent posts. For example we have a category for “fussball”, “verein”, “nachwuchs” etc. and each category has basically its own page where only the posts are displayed belonging to the category. It works with the current child theme. I copied the section where to define the category frm the current template and pasted it into the page.php and saved it under a new name. But only with this I do not get the pagenation. I copied+pasted the pagenation from index.php and put it after the <?php endwhile; ?> statement. So the pagenation is showing but does not work. When I click the next page the browser still stays on the first post page.

Sorry for the long intruduction/description but I hope you understand my problem.

Here is also the code of the template I created:

<?php
/*	Template Name: Verein	*/

get_header(); ?>

	
		
		
			

			query('cat=10');
			?>
			have_posts()) : $wp_query->the_post(); ?>

				

				

				
				 ' ' . __( 'Newer posts', 'sparkling' ),
							'next_text' => __( 'Older posts', 'sparkling' ) . ' ' ,
						) );
				?>

			<!-- #main -->
	<!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

Please help me :slight_smile:

<?php
/*	Template Name: Verein	*/
get_header(); ?>
	
		
			
			query('cat=10');
			?>
			have_posts()) : $wp_query->the_post(); ?>
				
				
				
				 ' ' . __( 'Newer posts', 'sparkling' ),
							'next_text' => __( 'Older posts', 'sparkling' ) . ' ' ,
						) );
				?>
			<!-- #main -->
	<!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>

I think the code was not display entirely.

Can you please advise?

Hi @ondry,

I hope you are well today and thank you for your question.

You should not modify WordPress main query instead you can create new query using WP_Query class.

You can use category and pagination parameters in it as described below.

https://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
https://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters

To display pagination you can use function the_posts_pagination

Best Regards,
Movin