• 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

rgval

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
  • Profile
  • Topics Started
  • Replies Created
  • Engagements
  • Favorites

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • June 12, 2015 at 1:54 pm in reply to: List of post by taxonomy #156010
    rgval
    Member

    I am so sorry, guys, it was a mistake in my taxonomy name.
    I used 'year' as the taxonomy term, and is reserved for WP.

    I am still surprised about how difficult is to list posts grouped by a custom taxonomy in an archive.
    I thought it could be easier with Genesis (perhaps I'm doing something wrong and there is an easier way...)

    Anyway, the working code is here:

    <?php
    /**
     * STUDENT ARCHIVE
     */
    
    // Replace the genesis loop
    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'my_custom_loop' );
    
    function my_custom_loop() {
    //start by fetching all terms for the year taxonomy
        $terms = get_terms( 'graduation-year', array(
           'orderby'    => 'name',
           'order' => 'DESC'
        ) );
    
    // now run a query of students for each year
        foreach( $terms as $term ) {
     
        // Define the query
            $args = array(
                'post_type' => 'student',
                'graduation-year' => $term->slug
            );
            $query = new WP_Query( $args );
                
            // output the term name in a heading tag                
            echo'<h2>' . $term->name . '</h2>';
        
            // output the post titles in a list
        echo '<ul>';
        
                // Start the Loop
                while ( $query->have_posts() ) : $query->the_post(); ?>
     
                <li class="student-list" id="post-<?php the_ID(); ?>">
                       <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                </li>
                <?php endwhile;
        echo '</ul>';
         // use reset postdata to restore orginal query
        wp_reset_postdata();
      }
    }
    
    genesis();
    ?>
    June 12, 2015 at 12:48 pm in reply to: List of post by taxonomy #155995
    rgval
    Member

    Thanks braddalton. What I am trying to do is a template for the custom post archive, so I can list all posts in one page.

    I am surprised is it not more easy to list posts by years...(not the publication year, but a custom numeric field). Apart from my problems with the loop, I though this should a be quite common way of sorting content. I am doing something wrong? perhaps another more efficient structure in the posts, etc.

    June 12, 2015 at 12:45 pm in reply to: List of post by taxonomy #155994
    rgval
    Member

    😀 Yes, good point. I do have post with every taxonomy.
    I confirmed they work with the taxonomy permalink

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)

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