• 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

Grid layout "almost" working but…

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 › Grid layout "almost" working but…

This topic is: not resolved

Tagged: grid css php loop

  • This topic has 5 replies, 4 voices, and was last updated 12 years, 1 month ago by cosmocanuck.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • August 21, 2014 at 10:35 pm #120397
    cosmocanuck
    Member

    Hi all! I'm working on a category template based on the info in this great tutorial by Jonathan Perez:

    http://surefirewebservices.com/development/genesis-framework/genesis-grid-style-page-template-with-custom-post-type

    However, my code must not be quite right as I'm getting all my posts assigned the "first" class, so they all stay in the first column! Here's my little template:

    http://pastebin.com/mrMiQ68P

    I've used the precise loop logic in Jonathan's example so not sure why the correct classes aren't being assigned... I am only an advanced newbie / junior guru at this point so I hope it isn't something TOO obvious... thanks!

    http://impressiveliving.ca/wp/category/steam-showers/
    August 21, 2014 at 11:08 pm #120401
    Brad Dalton
    Participant

    Try this http://wpsites.net/web-design/display-posts-in-columns-on-genesis-archive-pages/


    Tutorials for StudioPress Themes.

    August 21, 2014 at 11:54 pm #120411
    Genesis Developer
    Member

    Actually problem is here global $loop_counter; . The variable is not working properly. Please try this code. It'll help you:

    function sf_post_class($classes) {
        global $wp_query;
        $classes[] = 'one-third';
        if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % 3 )
    	 $classes[] = 'first';
    
        return $classes;
    }

    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    August 22, 2014 at 8:38 am #120474
    surefirewebserv
    Member

    You need to define $loop_counter before using it. Gen 2.0 removed it but kept it in the legacy loop for older verions.

    $loop_counter = $wp_query->current_post;

    Once that's defined then you can use global $loop_counter

    Take a look at this post: http://surefirewebservices.com/development/genesis-framework/easy-genesis-grid-loop-for-your-theme which is a refinement of the grid loop with 2 functions.


    SureFireWebServices.com | Genesis Tuts and More
    Genesis Theme Starter Kit | It’s Free

    August 22, 2014 at 9:21 am #120483
    cosmocanuck
    Member

    Thank you thank you thank you EVERYONE! @genwrock, your code worked perfectly of course. Meanwhile I will check out your links, @suefirewebserv and @braddalton, for deeper understanding and - as always - more learning! Thanks again!

    August 22, 2014 at 9:40 am #120485
    cosmocanuck
    Member

    @surefirewebserv, I realized that I should have read the link you posted - Jonathan actually had a link to that updated post at the top of his previous one i'd been working off - which of course IS outdated. Sigh.... Thanks again.

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 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

© 2026 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