• Skip to primary navigation
  • Skip to main content
OsomCode

OsomCode

Awesome code tutorials for WordPress and Genesis

  • Subscribe
  • My account
    • Edit profile
    • Favorites
    • Update credit card
  • Login

Change the number of posts per page by category in WordPress

Learn how to modify the number of entries per page of a given category in WordPress using code.

WordPress allows you to choose how many posts you want to display per page (in Settings > Maximum number of entries to display on the site).

But what if you want to enter more or less posts from a particular category?

Well, thanks to WordPress’ conditional tags, you can do it easily.

Find out how:

Snippet to change the number of posts per page from a specific category

Add this fragment to the end of the functions.php file:

To see this and another 847 code snippets of this website, login or subscribe here.

Ready! You will now display 12 posts from the ‘tutorials’ category per page.

Obviously, you can adjust both the category and the number of posts to your needs.

Conclusions

Now you know how to display the number of entries you or your client wants depending on their category.

If you have any question, please leave it in the comments. And if you want to give me a suggestion for future snippets, please send it through the contact form.

Benefits of being a subscriber. 🙂

PHP Post WordPress

To leave read and make questions about this code, you can login or register.

  • About OsomCode
  • FAQ
  • Contact

Legal Notice · Privacy Policy · Cookie Policy · Terms and conditions
Copyright © 2023

Lost your password?