Gateway home site – featured and recent posts
-
I’m using Gateway theme, and I’ve made a page to be the home site of my blog. I’d like to have the both the featured posts on that site, and the recent posts below them. How can I do that?
Thank You!
-
What do you mean by “featured posts?” I have the Gateway theme installed but am not seeing an option to set a post as “featured.” Is this a category you’ve set up?
In general you can customize a page by creating a custom page template.
You can create a new homepage, that has featured posts like that
I’d like the same, but with the recent ones below .
I gotcha. I don’t think this theme offers this on it’s own and will take some customization.
Depending on how comfortable you are with code, you’ll want to look at template-home.php. This is the template your new home page is using. Essentially you need to duplicate the loop and pull in the template-parts/content.php template.
If you replace all the code in the template-home.php file with the below, it should be what you’re looking for. Though I’d keep a back up of the file just in case! 🙂
<?php /** * * Template Name: Home * */ get_header( 'home' ); ?> <div class="home_posts_titles"> <div class="row"> <div class="large-12 columns"> <?php if ( get_theme_mod( 'home_posts_title' ) ) { $home_posts_title = get_theme_mod( 'home_posts_title' ); ?> <h2><?php echo esc_attr( $home_posts_title ); ?></h2> <?php } // end home_posts_title if ( get_theme_mod( 'home_posts_subtitle' ) ) { $home_posts_subtitle = get_theme_mod( 'home_posts_subtitle' ); ?> <h3><?php echo esc_attr( $home_posts_subtitle ); ?></h3> <?php } // end home_posts_subtitle ?> </div><!-- .large-12 --> </div><!-- .row --> </div><!-- .home_posts_titles --> <div class="featured-posts"> <div class="row"> <?php // Get chosen category $home_posts_cat = esc_attr( get_theme_mod( 'home_posts_cat' ) ); // WP_Query arguments $args = array ( 'post_type' => 'post', 'cat' => $home_posts_cat, 'posts_per_page' => '3', 'post__not_in' => get_option('sticky_posts'), ); // The Query $query = new WP_Query( $args ); // The Loop if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); get_template_part( 'template-parts/content', 'home' ); } } else { get_template_part( 'template-parts/content', 'none' ); } // Restore original Post Data wp_reset_postdata(); ?> </div><!-- .row --> </div><!-- .featured-posts --> <hr> <div class="row"> <?php // WP_Query arguments $args = array ( 'post_type' => 'post' ); // The Query $query = new WP_Query( $args ); // The Loop if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); get_template_part( 'template-parts/content', '' ); } } else { get_template_part( 'template-parts/content', 'none' ); } // Restore original Post Data wp_reset_postdata(); ?> </div> <hr> <div class="row home-content"> <div class="large-12 columns"> <?php the_content(); ?> </div><!-- .large-12 --> </div><!-- .home-content --> <?php get_footer(); ?>Sorry, but can you somehow simplify it, or explain it in detail. I’m totally new on WordPress. I’d be grateful if you could help me with this one.
Thank You very muchSorry, that wasn’t real clear. Try this:
- Download the Gateway child theme, unzip it, and put it in your wp-content/themes folder
- Activate the child theme in your control panel (Appearance > Themes)
- Copy template-home.php from the gateway folder and paste it into the gateway-child folder
- Paste the below code on line 77 in gateway-child/template-home.php.
<div class="row"> <?php // WP_Query arguments $args = array ( 'post_type' => 'post' ); // The Query $query = new WP_Query( $args ); // The Loop if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); get_template_part( 'template-parts/content', '' ); } } else { get_template_part( 'template-parts/content', 'none' ); } // Restore original Post Data wp_reset_postdata(); ?> </div> <hr>Let me know if this is what you’re looking for and if it makes sense. 🙂
Good luck!
The topic ‘Gateway home site – featured and recent posts’ is closed to new replies.