• 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

Weird loop behavior – Genesis child theme

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 › Weird loop behavior – Genesis child theme

This topic is: not resolved

Tagged: Custom Post Type, genesis, pagination

  • This topic has 3 replies, 3 voices, and was last updated 11 years, 9 months ago by nuggetweb.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • August 21, 2014 at 4:30 pm #120352
    nuggetweb
    Member

    I'm using a custom post type ("attraction") with a Genesis child theme (education) and I'm having some really strange behavior with the loop.

    I have it set to display 10 posts, which it does, but after the 3rd post the page alignment goes haywire and the posts start lining up against the left-hand side of the page. What's worse is that when you try to go to page 2 it just shows you the same posts as page 1.

    This is the dev address where I'm having issues:

    http://hcedc.nuggetweb.com/attraction/

    Here is the template I'm using for the archive:

    <?php 
    /* 
    Template Name: Attractions Template
    */ 
    remove_action('genesis_loop', 'genesis_do_loop');
    
    // Output our own post meta
    add_filter( 'genesis_post_info', 'attraction_post_archive_info' );
    
    // Output for custom post type 'attraction'
    add_action('genesis_post_content', 'hcedc_attraction_filter_archive');
    
    /**
     * Function that replaces the default loop
     * with a custom loop querying 'PostType' CPT.
    */
    add_action('genesis_loop', 'gt_custom_loop');
    
    function hcedc_attraction_filter_archive() {
        $addr1 = genesis_get_custom_field('hcedc_addr_text');
        $city  = genesis_get_custom_field('hcedc_city_text');
        $phone = genesis_get_custom_field('hcedc_phone_text');
        $zip   = genesis_get_custom_field('hcedc_zip_text');
        
        $post_meta  = '<p class="hcedc">' . $city . '</p>';
        $map_addr   = $addr1 . "," . $city . ",IL," . $zip;
        $map        = hcedc_google_map($map_addr,300,150);
    
        $table = $single . '
        <table border="1">
            <tr>
                <td style="vertical-align: top;">' . $map . '</td>
            </tr>
        </table>
        </div>
        ';
        echo $table;
    }
    
    function gt_custom_loop() {
        global $paged;
        $wp_query = null; 
        $wp_query = new WP_Query(); 
     
        $args = array('post_type' => 'attraction','orderby' => 'title', 'order' => 'ASC','paged='.$paged);
        // Accepts WP_Query args 
        // (http://codex.wordpress.org/Class_Reference/WP_Query)
        genesis_custom_loop( $args );
     
    }
    
    function attraction_post_archive_info() {
        $addr1    = genesis_get_custom_field('hcedc_addr_text');
        $addr2    = genesis_get_custom_field('hcedc_addr2_text');
        $city     = genesis_get_custom_field('hcedc_city_text');
        $zip      = genesis_get_custom_field('hcedc_zip_text');
        $phone    = genesis_get_custom_field('hcedc_phone_text');
        
        if ( !is_page() ) { return the_category(', '); }
    }
    
    genesis(); // <- everything important: make sure to include this. 
    
    ?> 

    Any ideas where to turn? Thanks!

    http://hcedc.nuggetweb.com/attraction/
    August 21, 2014 at 7:21 pm #120377
    Lauren @ OnceCoupled
    Member

    Formatting: You have an unnecessary closing div in your code. Remove that! 🙂


    We create mobile-first, PageSpeed-optimized, pixel-perfect custom themes! https://www.oncecoupled.com

    August 21, 2014 at 7:53 pm #120384
    DTHkelly
    Member

    Do you need the closing ?> aftergenesis(); ?

    August 21, 2014 at 8:21 pm #120387
    nuggetweb
    Member

    Thanks Lauren! The div was a left-over from a previously tried layout, but that did the trick.

    I figured out the problem with the pagination as well. I was missing the posts_per_page, and I wasn't grabbing the page correctly.

    I think everything is golden now. Thank you!

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