Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #102788
    Valeska
    Participant

    Hello!
    I would like to have a post page, but leave the recent posts on the homepage?
    My website: valeskasalvador.conducere.com.br

    Thank you,
    Valeska

    #102826
    Mahesh
    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('&larr; Older Posts'); ?></div>
            	<div class="nav-next"><?php previous_posts_link('Newer Posts &rarr;'); ?></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('&larr; 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

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.