- This topic has 1 reply, 2 voices, and was last updated 6 years, 11 months ago by
Mahesh.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
November 3, 2016 at 8:43 pm #102788
Valeska
ParticipantHello!
I would like to have a post page, but leave the recent posts on the homepage?
My website: valeskasalvador.conducere.com.brThank you,
ValeskaNovember 4, 2016 at 9:55 am #102826Mahesh
Keymaster@valeska: For this, you’ll need to create a child theme. You can find more details on creating child theme HERE. Then in your child theme, create a new-file for page template, and add the following code:
<?php /** * Template Name: My page * */ get_header(); ?> <main id="main" class="site-main" role="main"> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', 'page' ); ?> <?php /** * fullframe_comment_section hook * * @hooked fullframe_get_comment_section - 10 */ do_action( 'fullframe_comment_section' ); ?> <?php endwhile; // end of the loop. ?> <?php // Display blog posts on any page $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('&paged='.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <?php /* Include the Post-Format-specific template for the content. * If you want to override this in a child theme then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( 'content', get_post_format() ); ?> <?php endwhile; ?> <?php if ($paged > 1) { ?> <nav id="nav-below" role="navigation"> <h3 class="screen-reader-text">Post navigation</h3> <div class="nav-previous"><?php next_posts_link('← Older Posts'); ?></div> <div class="nav-next"><?php previous_posts_link('Newer Posts →'); ?></div> </nav> <?php } else { ?> <nav id="nav-below" role="navigation"> <h3 class="screen-reader-text">Post navigation</h3> <div class="nav-previous"><?php next_posts_link('← Older Posts'); ?></div> </nav> <?php } ?> <?php wp_reset_postdata(); ?> </main><!-- #main --> <?php get_sidebar(); ?> <?php get_footer(); ?>
Then add a new page and select this custom template, then it will display the page content along with the recent posts.
Note: Please make sure you have selected the very page as the static front page.
Regards,
Mahesh -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- The topic ‘Is it possible to create a post page and put the recent posts on the homepage?’ is closed to new replies.