Posts per Page per Catagory

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

This topic is: not resolved

This topic contains 4 replies, has 2 voices, and was last updated by  UglyMutt 1 year, 7 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #23271

    UglyMutt
    Participant
    Post count: 4

    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.

    #23281

    braddalton
    Participant
    Post count: 9922

    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
    [php]
    !is_home()
    [/php]

    You’ll need to add this code to a custom function.
    [php]
    <?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; ?>
    [/php]
    Source: http://www.wprecipes.com/how-to-define-how-many-post-to-display-per-page


    #23310

    UglyMutt
    Participant
    Post count: 4

    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.

    #23316

    braddalton
    Participant
    Post count: 9922

    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


    #23331

    UglyMutt
    Participant
    Post count: 4

    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.

     

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.