• 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

Display Posts by Category on Page

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 › Display Posts by Category on Page

This topic is: resolved
  • This topic has 4 replies, 2 voices, and was last updated 10 years, 10 months ago by Brad Dalton.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • April 25, 2015 at 10:30 am #149142
    readytoblogdesigns
    Member

    So! I've made it much farther than I thought I would with this and it's a bit cobbled together, I'm looking for just a nudge to get me over the finish line.

    I've constructed a page template that displays the page content (yay!) and paginated posts by category (double-yay!).

    What I ultimately want to do, though, becomes ridiculous when I have 20+ pages that with this method would each need a template file (and for me to specifically input the category ids). That's ridiculous, right? Is there a way to modify this so that within the edit page window my client can choose this page template and use a custom field to choose which category to display? I'm not sure if this is something glaringly obvious but I've gotten this far and now my eyeballs hurt. Any assistance would be so very appreciated!!

    (Note: this page needs pagination which is why I haven't used any of the available options out there. I'd like it to be as simple as the method that involves selecting the blog template and using query_args...I'm not sure if that's possible?)

    <?php
    /* Template Name: Location */

    remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop
    add_action( 'genesis_loop', 'genesis_standard_loop', 5 ); // show the editor content

    add_action( 'genesis_before_loop', 'wpsites_before_blog_widget' );
    function wpsites_before_blog_widget() {
    if( !is_paged() ) {
    genesis_widget_area( 'before-blog', array(
    'before' => '<div class="before-blog widget-area">',
    'after' => '</div>',
    ));
    }
    }

    add_action( 'genesis_loop', 'rgc_do_loop' ); // Add custom loop
    function rgc_do_loop() {

    global $post;
    // arguments, adjust as needed
    $args = array(
    'post_type' => 'post',
    'posts_per_page' => 6,
    'category__in' => array(144,225,108),
    'post_status' => 'publish',
    'paged' => get_query_var( 'paged' )
    );

    /*
    Overwrite $wp_query with our new query.
    The only reason we're doing this is so the pagination functions work,
    since they use $wp_query. If pagination wasn't an issue,
    use: https://gist.github.com/3218106
    */
    global $wp_query;
    $wp_query = new WP_Query( $args );

    if ( have_posts() ) :

    echo '<div class="cat-posts">';

    while ( have_posts() ) : the_post();
    echo '<div class="cat-listing">';
    echo '<div class="entry-title"> ' . get_the_title() . ' </div>'; // show the title
    echo '<div class="cat-date">';
    echo the_date();
    echo '</div>';
    if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
    the_post_thumbnail( 'thumbnail', array( 'class' => 'alignleft' ) );
    }
    echo get_the_excerpt();
    echo '</div>';
    endwhile;

    echo '</div>';
    do_action( 'genesis_after_endwhile' );
    endif;

    wp_reset_query();
    }

    genesis();

    April 25, 2015 at 11:24 am #149154
    Brad Dalton
    Participant

    The code is broken as it isn't embedded using the suggested method. http://www.studiopress.community/faq/#code


    Tutorials for StudioPress Themes.

    April 25, 2015 at 11:33 am #149156
    readytoblogdesigns
    Member

    Oops - sorry!

    Let's see if this works:

    April 26, 2015 at 8:08 am #149186
    readytoblogdesigns
    Member

    I found a working solution in case this helps anyone! 🙂

    June 6, 2015 at 8:01 am #155105
    Brad Dalton
    Participant

    Try this http://wpsites.net/wordpress-tips/display-posts-from-each-category-on-1-page/


    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Display Posts by Category on Page’ 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

© 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