• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Posts per Page per Catagory

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Posts per Page per Catagory

This topic is: not resolved

Tagged: posts per page

  • This topic has 4 replies, 2 voices, and was last updated 10 years, 6 months ago by UglyMutt.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • February 28, 2013 at 8:58 am #23271
    UglyMutt
    Member

    Hello. I am having a bit of difficulty figuring out how to change the number of posts displayed on a per category basis. My homepage is currently functioning as wished with this modification:

    add_action( 'pre_get_posts', 'child_change_home_query' );
    /** Changes the query on the home page*/
    function child_change_home_query( $query ) {

    if( $query->is_main_query() && $query->is_home() ) {
    $query->set( 'posts_per_page', '17' );
    $query->set('cat', '-1,');
    }

    }

    Now I wish to change how many posts show per category per page without it effecting my homepage. Most of my posts are fairly long with the exception of my "New Releases" category. I would like to set all categories to show 3 posts per page while the "New Releases" category shows 10 posts per page. If someone could offer any suggestions, I would be truly grateful.

    If a point of reference is needed, my website is TopList-BestFictionBooks.com .

    Thanks.

    February 28, 2013 at 9:33 am #23281
    Brad Dalton
    Participant

    Did you try this plugin http://wordpress.org/extend/plugins/posts-per-category/

    You could also modify code and add the conditional tag so it doesn't effect your home page

    !is_home()
    

    You'll need to add this code to a custom function.

    <?php
    $page_num = $paged;
    if ($pagenum='') $pagenum =1;
    query_posts('showposts=3&paged='.$page_num); ?>
                   	<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?> 
                    // WordPress loop
                    endwhile;endif; ?>
    

    Source: http://www.wprecipes.com/how-to-define-how-many-post-to-display-per-page


    Tutorials for StudioPress Themes & WooCommerce.

    February 28, 2013 at 11:18 am #23310
    UglyMutt
    Member

    Thank you for your response, Mr. Dalton. This is my first website attempt and, sorry to say, I'm not very savvy in the world of code and all it entails. I know it would be much simpler to use a plug-in to achieve the aesthetics I wish; however, I was told to shy away from plug-ins that aren't deemed absolutely necessary and I already have three I feel imperative to my website. I was told plug-ins slow response time, not that I know exactly what that means, but I understood it to be negative.

    Above, you mentioned adding the suggested code to a custom function. I googled custom functions for a tutorial and what I found was a bit confounding. Would you be able to point me to a simplified tutorial on how to create a custom function that even a novice would understand?

    Thank you so very much for your help.

    February 28, 2013 at 12:07 pm #23316
    Brad Dalton
    Participant

    I think the plugin is a better solution for you at this stage.

    Doubt it will have any real affect on performance more than code will.

    Coding would reqiure knowledge of conditional tags, query posts and the Genesis Loop.

    http://www.w3schools.com/php/default.asp


    Tutorials for StudioPress Themes & WooCommerce.

    February 28, 2013 at 1:18 pm #23331
    UglyMutt
    Member

    Thank you once again, Mr. Dalton. The tutorial you suggested is perfect for my level of understanding. In the mean time, I think I will just live with the aesthetic issue while I'm learning the nuts and bolts of code. I truly appreciate your assistance and wish you the best.

     

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble