• 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

preahkumpii

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
  • May 10, 2016 at 9:00 am in reply to: Secondary Genesis Loop for Related Posts in single.php #185358
    preahkumpii
    Member

    I figured it out. Maybe it will help someone else.

    All of the code was put into the functions.php file. I did not have to touch the single.php file.

    add_image_size( 'pst-related-posts-thumb', 250, 250, array( 'center', 'top' ) );  //for related posts
    add_action( "genesis_loop", "pst_related_posts" );
    
    function pst_related_posts() {
        if ( is_single() ) {  //make sure related posts only shows on single posts
            $my_cats = get_the_category();
            $my_cat_id = $my_cats[0]->cat_ID;  //gets the current post category id; must be done in loop
            $args = array(  //sets arguments for get_posts() function, including get only posts with current post category id
                'posts_per_page'   => 12,  //this number should be several more than the number of posts to show
                'category'         => $my_cat_id,
                'orderby'          => 'rand'
            );
            $posts_array = get_posts( $args );
            echo "<div class='pst-related-posts'>";
            echo "<h3>We think you'll love this momspiration too!</h3>";
            echo "<ul>";
            $count = 0;
            foreach ($posts_array as $my_post) {
                if ( !has_post_thumbnail( $my_post ) ) {
                    continue;
                }
                //cycle through each matched post and get needed info (title, url, thumbnail, etc.)
                $title = $my_post->post_title;
                $link = get_permalink($my_post);
                $thumb = get_the_post_thumbnail($my_post, "pst-related-posts-thumb");
                echo "<li>";
                echo "<h4><a href='" . $link . "' target='_self' title='" . $title . "'>" . $title . "</a></h4>";
                echo "<a href='" . $link . "' target='_self' title='" . $title . "'>" . $thumb . "</a>";
                echo "<a href='" . $link . "' target='_self' title='" . $title . "'><div class='pst-related-posts-button'>Read it now &rarr;</div></a>";
                echo "</li>";
                $count++;
                if ( $count == 6 ) {  //this is the number of posts to show
                    break;
                }
            }
            echo "</ul>";
            echo "</div>";
        }
    }
    May 8, 2016 at 6:19 pm in reply to: Secondary Genesis Loop for Related Posts in single.php #185236
    preahkumpii
    Member

    Thanks. I was actually hoping to streamline this process by not using a plugin. We already have dozens of plugins and I don't really want to add to the bloat. So I'm hoping for a code snippet with the basics...

    Adam

    February 19, 2016 at 4:37 pm in reply to: How to move the post title to after the post image in custom genesis grid loop? #179424
    preahkumpii
    Member

    In home.php (also archive.php). The archive page in question is the home page.

    <?php
    remove_action( 'genesis_entry_content', 'genesis_grid_loop_content' );
    //* Add support for Genesis Grid Loop
    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'child_grid_loop_helper' );
    function child_grid_loop_helper() {
      if ( function_exists( 'genesis_grid_loop' ) ) {
    		genesis_grid_loop( array(
    			'features' => 0,
    			'feature_image_size' => 'full',
    			'feature_image_class' => 'grid-first-featured',
    			'feature_content_limit' => 500,
    			'grid_image_size' => 'grid-thumbnail',
    			'grid_image_class' => 'grid-featured',
             //'grid_content_limit' => 100,
    			'more' => __( 'Continue Reading', 'genesis' ),
    		) );
    	} else {
    		genesis_standard_loop();
    	}
    }
    
    genesis();
    ?>
  • 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

© 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