• 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

Desperately need help with custom loop in archive

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 › General Discussion › Desperately need help with custom loop in archive

This topic is: resolved

Tagged: ACF, Custom fields, custom loop

  • This topic has 6 replies, 2 voices, and was last updated 7 years, 8 months ago by photoaddictsa.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • September 22, 2017 at 11:18 am #211757
    photoaddictsa
    Member

    Hi,

    I'm still learning here, decided to give a custom loop a try.

    I've got the loop displaying the info I wanted but the code output is all wonky.

    Here is the whole code: (I'm using ACF)

    <?php
    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'your_custom_loop' );
    
    // Remove custom structural wraps.
    remove_action( 'genesis_before_content_sidebar_wrap', 'studio_wrap_open', 6 );
    remove_action( 'genesis_after_content_sidebar_wrap', 'studio_wrap_close', 13 );
    
    function your_custom_loop() {
    
    if(have_posts()) : while(have_posts()) : the_post();
    
    echo '<article class="entry">';
        
    echo '<div class="entry-content">';
        
        
        echo '<div class="won_by">';
                get_field('team_won_by_x_runs');
        echo '</div>';
    
        
        echo '<ul class="tvst">';
        
            echo '<li class="team1">';
    
                    echo '<img src="' . get_field('team_1_photo') . '" alt="" />';
                
                	echo '<span class="runswwickets">' . get_field('team_1_runs_wickets') . '</span>';
                
            echo '</li>';
            
            echo '<li class="vs">';
            
                	echo '<h3 class="teamname">' . get_field('team_1') . '</h3>';
                
                echo '<em class="vs">' . VS . '</em>';           
                
                	echo '<h3 class="teamname">' . get_field('team_2') . '</h3>';
                
    			echo '<div class="date-venue">';
            
    		    echo '<div class="date">';
    		                get_field('date'); echo '<em>(GMT+2)</em>';
    		        echo '</div>';
    		            
    		        echo '<div class="venue">';
    		                get_field('venue');
    		    echo '</div>';
            
            echo '</li>';
            
            echo '<li class="team2">';
    
                    echo '<img src="' . get_field('team_2_photo') . '" alt="" />';
                
                	echo '<span class="runswwickets">' . get_field('team_2_runs_wickets') . '</span>';
            
            echo '</li>';
            
        echo '</ul>';
                
        echo '</div>';
    
    echo '</div>';
    echo '</article>';
    
    endwhile; endif;	
    
    }
        
    genesis();

    This the output:
    output

    One is inside <main and other is not, where did I mess up?

    http://nmbstars.co.za/nmbs/fixtures/
    September 22, 2017 at 11:35 am #211758
    Brad Dalton
    Participant

    I would post the code in a Github Gist and link to it from here.


    Tutorials for StudioPress Themes.

    September 22, 2017 at 1:17 pm #211761
    photoaddictsa
    Member

    Thanks for the advice Brad, here is the gist link: https://gist.github.com/photoaddictsa/2343851119a91523940de538a831ac57

    September 25, 2017 at 2:00 am #211835
    Brad Dalton
    Participant

    Can't test without setting up ACF.


    Tutorials for StudioPress Themes.

    September 26, 2017 at 4:56 am #211866
    photoaddictsa
    Member

    Figured it out, I was over thinking the whole thing a bit.

    Working through some of your other tutorials actually helped me figure it out 🙂

    September 26, 2017 at 5:27 pm #211879
    Brad Dalton
    Participant

    Cool. 2 things you might want to consider :

    1. Use get_post_meta in replace of get_field

    2. Use class_exists to check ACF is active


    Tutorials for StudioPress Themes.

    September 26, 2017 at 11:45 pm #211908
    photoaddictsa
    Member

    Ah ok, awesome! Thanks very much.

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘General Discussion’ 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

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