• 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 Loop

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 Loop

This topic is: not resolved

Tagged: grid loop

  • This topic has 1 reply, 2 voices, and was last updated 10 years, 6 months ago by Brad Dalton.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • November 24, 2015 at 7:13 am #171912
    Tmgale
    Member

    I am trying to add a grid loop to CPTs on a page.

    Does anyone know how I can adjust post class filter to work on a custom wp_query?

    I cant seem to get it to work on a custom loop that I write. It words when I use ;

    genesis_custom_loop( $args );

    Need it work with my custom loop, any ideas?

    The filter snippet is below and the full code snippet is beneth that.

    
     //Add Post Class Filter
    add_filter('post_class', 'tg_post_class');
    function tg_post_class($classes) {
    	global $loop_counter;
    	$classes[] = 'one-third';
    	if (($loop_counter + 3) % 3 == 0) {
    		$classes[] .= 'first';
    	}
    	$loop_counter++;
    	return $classes;
    }
    

    Here is the full code.

    <?php
    
    /**
    * Template Name: Custom Grid Loop Test 
    */
    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'my_custom_loop' );
    
    function my_custom_loop() {
    
    	global $paged;
    
    	// accepts any wp_query args
    	$args = (array(
    		'post_type'      => 'movie', 
    	 	'paged'          => $paged,
    	 	'posts_per_page' => 6 
    	));
    
    	// The Query
    $query = new WP_Query( $args );
    
    // The Loop
    if ( $query->have_posts() ) {
    	while ( $query->have_posts() ) {
    		$query->the_post();
    		the_title();
    		
    		
    	}
    } else {
    	// no posts found
    }
    
    //Add Post Class Filter
    add_filter('post_class', 'tg_post_class');
    function tg_post_class($classes) {
    	global $loop_counter;
    	$classes[] = 'one-third';
    	if (($loop_counter + 3) % 3 == 0) {
    		$classes[] .= 'first';
    	}
    	$loop_counter++;
    	return $classes;
    }
    
    }
    
    genesis();
    
    November 26, 2015 at 3:36 pm #172075
    Brad Dalton
    Participant

    You can use CSS for that http://wpsites.net/web-design/archive-page-grid-style-columns-using-css/


    Tutorials for StudioPress Themes.

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