• 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

Custom Loop for Post Listings (Blog, Categories, Tags, everything)

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 › Custom Loop for Post Listings (Blog, Categories, Tags, everything)

This topic is: resolved

Tagged: custom loop, genesis loop

  • This topic has 1 reply, 1 voice, and was last updated 8 years, 3 months ago by Brad West.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • February 26, 2015 at 10:36 pm #142476
    Brad West
    Member

    I'd like to display blog and taxonomy pages with only the title and listed by year. I was able to get this to work using a page template for the main blog display (https://gist.github.com/bradonomics/2e51a419c46617a2fcac), but would rather have it display for every category and tag loop also.

    Any ideas how to alter the loop for this?

    February 27, 2015 at 2:21 am #142501
    Brad West
    Member

    Got it...

    I added an archive.php file to my theme with the below code.

    <?php
    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'bradonomics_archive_loop'  );
    function bradonomics_archive_loop() {
    
      $set_year = '';
    
      if ( have_posts() ) :
      while( have_posts() ) : the_post();
        if( $set_year == '' ) {
          $set_year = get_the_date(Y);
          echo '<div class="wrap"><div class="group-year"><p>' . get_the_date(Y) . '</p>';
        }
        else {
          if( $set_year != get_the_date(Y) ) {
            echo '</div>';
            echo '<div class="group-year"><p>' .get_the_date(Y) . '</p>';
            $set_year = get_the_date(Y);
          }
        }
    
        echo '<article>';
        echo '<h3><a href="'.get_the_permalink().'">'.get_the_title().'</a></h3>';
        echo '<time><span class="month">' . get_the_date(M) . '</span> <span class="day">' . get_the_date(j) . '</span> <span class="year">' . get_the_date(Y) . '</span></time>';
        echo '</article>';
    
      endwhile;
      endif;
    
    }
    
    genesis();
  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Custom Loop for Post Listings (Blog, Categories, Tags, everything)’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

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