How to custom limit posts in WordPress category without a plugin

Normally, The post shows in a category is ten or higher with your settings in WordPress Admin Dashboard -> Settings-> Reading. You can change this with the number that you want. In some case, you want to show other number with special category. For example: 10, 20, or higher.

In this post, I will help you how to custom limit posts in WordPress category without a plugin. By using simple php function and insert to your WordPress theme with two basic steps.

Step 1: Open your WordPress theme and find functions.php file.

function custom_post_per_category( $query )
	if(!$query->is_main_query()) {
	if ( is_category( 'video' ) )
		// If you want "showposts"
		$query->query_vars['showposts'] = 16;

add_action( 'pre_get_posts', 'custom_post_per_category' );

Step 2: Save and reload your category

Thanks for reading.

Share this :

No comments yet.

Leave a Reply

Related post

Free Responsive Website templates

ThemeVina is Best site for free sharing and download Wordpress themes, Joomla templates, Responsive website templates and more HTML templates.

All template in Site are free. You can download and install for your site.

Contact us

  • Brand: Theme Vina
  • Email:
  • Website:
  • Address: 367 Tran Hung Dao Street
  • Location: Thai Binh City, Thai Binh, Viet Nam