Adding Page Content and Last Recent Blog Post to Front page Panel
-
Hello, I been wrestling with this issue for days now.
I have been attempting to add the most recent blog entry to the front page panel area along with front page content within the same panel.
I am using the Twenty Seventeen theme with a child theme.
So far I have created a custom content-front-page template named content-front-page-homepage.php. This template is being loaded into front-page.php.
I’ve rearranged the code a bit in the above custom file (content-front-page-homepage) to bring to get the most recent blog entry to display in the panel along with homepage content.
my code below
<div class=”panel-content”>
<div class=”wrap-homepage”>
<?php if ( has_post_thumbnail() ) :
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘twentyseventeen-featured-image’ );// Calculate aspect ratio: h / w * 100%.
$ratio = $thumbnail[2] / $thumbnail[1] * 100;
?><?php endif; ?>
<!– .panel-image-hp –>
<div class=”panel-image-hp”>
<!– created new class div called header-panel-hp–>
<div class=”header-panel-hp”>
<header class=”entry-header”>
<?php the_title( ‘<h2 class=”entry-title”>’, ‘</h2>’ ); ?>
<?php twentyseventeen_edit_link( get_the_ID() ); ?>
</header><!– .entry-header –>
</div><!–.header-panel-hp–>
“/>
</div><!–.panel-image-hp –><div class=”entry-content-hp”>
<?php
/* translators: %s: Name of current post */
the_content( sprintf(
__( ‘Continue reading<span class=”screen-reader-text”> “%s”</span>’, ‘twentyseventeen’ ),
get_the_title()
) );
?>
</div> <!– .entry-content-hp –><div class=”recent-posts-hp”>
<?php // Show four most recent posts.
$recent_posts = new WP_Query( array(
‘posts_per_page’ => 1,
‘post_status’ => ‘publish’,
‘ignore_sticky_posts’ => true,
‘no_found_rows’ => true,
) );
?>
<?php if ( $recent_posts->have_posts() ) : ?>
<?php
while ( $recent_posts->have_posts() ) : $recent_posts->the_post();
get_template_part( ‘template-parts/post/content’, ‘image’ );
get_template_part( ‘template-parts/post/content’, ‘excerpt’ );
endwhile;
wp_reset_postdata();
?>
<?php endif; ?></div><!– .recent-posts –>
However, my problem is two things:
1)Is this the best solution to customize the panels for the front page or would custom post type solution be best or shortcode plugin?
2)I am trying to get the front page panel to look like the yellow section in the attached image link below. Would placing front page content and recent blog content in divs and using CSS inline-block style achieve this content structure?
Pleasssse any help!
- The topic ‘Adding Page Content and Last Recent Blog Post to Front page Panel’ is closed to new replies.