Reply To: Landing page with blog posts

#21551
gsallman
Participant

For anyone else looking for this feature, I have a solution but it involves re-purposing the theme’s existing blog page templates.

I’ve spent a lot of hours trying to get this to work with my own page template, but I’ve not been able to successfully ‘fix’ the javascript which uses the template filenames to invoke the masonry effect.

Here’s some example code for the ‘blog, full width’ page template.

1. Copy the file template-blog-full-width.php to your child theme.

2. Replace the code with the following:

<?php
/*
Template Name: Blog, Full Width

Edited to take the current page text and post it above the blog posts.

*/
?>
<?php get_header(); ?>

	<div id="container">

                <?php // Additional code to include the current page text on the first page only ?>
		<?php if( !is_paged() ): //Remove this if statement and corresponding endif if you want the page content on the top of every paginated blog page. ?> 
		<div id="Pagetext">
				<article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
					<div class="entry">
						<div class="entry-content">
							<?php the_content(); ?>
							<div class="clear"></div>
						</div><!-- .entry-content -->
					</div><!-- .entry -->
				</article><!-- .post -->
         	</div><!-- #Pagetext -->
		<?php endif; ?>
		<?php // End of additional code ?>

		<section id="content" class="column onecol">
			<?php $args = array( 'posts_per_page' => get_option( 'posts_per_page' ), 'paged' => max( 1, get_query_var( 'paged' ) ) ); ?>
			<?php if( pinboard_get_option( 'blog_exclude_portfolio' ) ) : ?>
				<?php $args['cat'] = '-' . pinboard_get_option( 'portfolio_cat' ); ?>
			<?php endif; ?>
			<?php global $wp_query, $wp_the_query; ?>
			<?php $wp_query = new WP_Query( $args ); ?>
			<?php if( $wp_query->have_posts() ) : ?>
				<div class="entries">
					<?php while( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
						<?php get_template_part( 'content', get_post_format() ); ?>
					<?php endwhile; ?>
				</div><!-- .entries -->
				<?php pinboard_posts_nav(); ?>
			<?php else : ?>
				<?php pinboard_404(); ?>
			<?php endif; ?>
			<?php wp_reset_postdata(); ?>
			<?php $wp_query = $wp_the_query; ?>
		</section><!-- #content -->
		<div class="clear"></div>
	</div><!-- #container -->
<?php get_footer(); ?>

3. Create a new page with the ‘Blog, Full Page’ template. Any text or code you put in the page will be inserted at the top of the page before the blog posts. I’ll leave my test page online. Currently, I just have a heading and a Revolution slider running at the top of the page. I prefer this to the theme’s in-built slider which relies on sticky posts. You can see the test page here: http://breakfastinamerica.me/this-is-a-landing-page/