Conditionally modifying the genesis loop?

Community Forums Forums General Discussion Conditionally modifying the genesis loop?

This topic is: not resolved

This topic contains 2 replies, has 2 voices, and was last updated by  jcole 1 year, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #33835

    jcole
    Participant
    Post count: 6

    I’m new to Genesis and working on a custom view of the individual category pages.

    I need to modify the default Genesis loop on the category archive pages in the following ways:

    1) Under certain conditions display posts 6-9 on any given category archive page. The reason for this is that I’m featuring a post slider for posts 1-5.

    Is there a recommended way of modifying the post query conditionally to include posts 6-9, and still have pagination work properly?

    2) Add a “last” post class to the last post in the loop. I need to format the last post on the page differently in CSS. Is there an easy way to do this?

    I was thinking that something like this might work, but I’m not sure how to conditionally tie into the last post in the post query:

    add_filter('post_class', 'custom_post_class');
    function custom_post_class($classes) {
    $new_class = 'last';
    If last post in result set
    $classes[] = esc_attr(sanitize_html_class($new_class));
    return $classes;
    }

    Thanks for any assistance.

    Best,
    John

    #38292

    cehwitham
    Participant
    Post count: 396

    Hi John,

    This post should help you replace the loop:

    http://genesissnippets.com/genesis-custom-loop/

    And this post might give you some ideas for the offset, the Genesis Grid loop has a features option and then offsets the standard listing:

    http://wpsmith.net/2013/genesis/genesis-grid-loop-in-genesis-1-9/

    Let me know if that helps.

    Chris


    Twitter: cehwitham Web: cehwitham.com

    #38395

    jcole
    Participant
    Post count: 6

    Thanks Chris!

    I came across those and similar posts and ended up using a custom loop to get it all working.

    Best,
    John

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

You must be logged in to reply to this topic.