• 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

How to Call Front-Page Posts in Two Sections

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 › How to Call Front-Page Posts in Two Sections

This topic is: not resolved

Tagged: front page, functions, No Sidebar

  • This topic has 1 reply, 2 voices, and was last updated 6 years, 6 months ago by Susan.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • March 17, 2016 at 2:36 pm #181728
    Nigel1985
    Participant

    I am looking to modify the way my front-page posts are called. Right now, the page displays all 7 posts one right after the other. I would like to call the first 3 and then insert a section header, then call posts 4-7. Basically, being able to interject Text into the post order.

    Something like:

    [Post 1: Featured Image ]
    [Post 2 ] [Post 3]

    Other Recent Posts
    [Post 4] [Post 5]
    [Post 6] [Post 7]

    Any thoughts or suggestions? Much appreciated!

    Here is my front-page.php

    
    <?php
    /**
     * This file adds the Front Page to the No Sidebar Pro Theme.
     *
     * @author StudioPress
     * @package No Sidebar
     * @subpackage Customizations
     */
     
     add_action( 'genesis_meta', 'ns_front_page_genesis_meta' );
    /**
     * Setup homepage posts grid.
     *
     */
    function ns_front_page_genesis_meta() {
    
    	if ( 'posts' == get_option( 'show_on_front' ) ) {
    
    		//* Remove breadcrumbs
    		remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
    
    		//* Remove entry content elements
    		remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
    		remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
    		remove_action( 'genesis_entry_content', 'genesis_do_post_content_nav', 12 );
    		remove_action( 'genesis_entry_content', 'genesis_do_post_permalink', 14 );
    
    		//* Remove the entry meta in the entry footer
    		remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
    		remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
    		remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
    		
    		//* Remove No Sidebar featured image
    		remove_action( 'genesis_entry_header', 'ns_featured_image', 1 );
    		
    		//* Add post classes
    		add_filter( 'post_class', 'ns_post_class' );
    		
    		//* Add first-page body class
    		add_filter( 'body_class', 'ns_body_class' );
    		
    		//* Add featured image above the entry content
    		add_action( 'genesis_entry_header', 'ns_front_featured_image', 4 );
    
    	}
    
    }
    
    //* Enqueue full screen script
    add_action( 'wp_enqueue_scripts', 'ns_full_screen_script' );
    function ns_full_screen_script() {
    
    	if ( is_active_sidebar( 'welcome-message' ) ) {
    
    		wp_enqueue_script( 'ns-full-screen', get_stylesheet_directory_uri() . '/js/full-screen.js', array( 'jquery' ), '1.0.0' );
    
    	}
    
    }
    
    //* Hook welcome message widget area after site header
    add_action( 'genesis_after_header', 'ns_welcome_message' );
    function ns_welcome_message() {
    
    	if ( get_query_var( 'paged' ) >= 2 )
    		return;
    
    	echo '<div class="full-screen"><div class="widget-area">';
    
    	echo '<h2 class="screen-reader-text">' . __( 'Welcome Content', 'no-sidebar' ) . '</h2>';
    
    	genesis_widget_area( 'welcome-message', array(
    		'before' => '<div class="welcome-message"><div class="wrap">',
    		'after'  => '</div></div>',
    	) );
    
    	echo '</div></div>';
    
    }
    
    function ns_post_class( $classes ) {
    
    	global $wp_query;
    
    	$current_page = is_paged() ? get_query_var('paged') : 1;
    
    	$post_counter = $wp_query->current_post;
    
    	if ( 0 == $post_counter && 1 == $current_page ) {
    		$classes[] = 'first-featured';
    	}
    
    	if ( ( $post_counter & 1 ) && 1 == $current_page ) {
    		$classes[] = 'row';
    	} elseif ( ( $post_counter % 2 == 0 ) && 1 !== $current_page ) {
    		$classes[] = 'row';
    	}
    
    	if ( ( $wp_query->current_post + 1 ) == $wp_query->post_count ) {
    		$classes[] = 'last';
    	}
    
    	return $classes;
    
    }
    
    function ns_body_class( $classes ) {
    
    	$current_page = is_paged() ? get_query_var('paged') : 1;
    
    	if ( 1 == $current_page ) {
    		$classes[] = 'first-page';
    	}
    
    	$classes[] = 'front-page';
    
    	return $classes;
    
    }
    
    function ns_front_featured_image() {
    
    	if ( $image = genesis_get_image( array( 'format' => 'url', 'size' => 'ns-featured', ) ) ) {
    
    		printf( '<a class="ns-featured-image" href="' . get_permalink() . '" style="background-image: url(%s)"></a>', $image );
    
    	}
    
    }
    
    //* Run the Genesis function
    genesis();
    
    http://add1tbsp.com
    September 30, 2016 at 12:00 pm #194005
    Susan
    Moderator

    I would use the StudioPress column classes on a static front page.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Design Tips and Tricks’ 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

© 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