Skip to main content
added 1434 characters in body
Source Link

EDIT

Contents of loop.php as requested in reply :)

<?php if (have_posts()): while (have_posts()) : the_post(); ?> <!-- article --> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <!-- post thumbnail --> <?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="h-entry__image-link"> <?php the_post_thumbnail(array(120,120)); // Declare pixel size you need inside the array ?> </a> <?php endif; ?> <!-- /post thumbnail --> <!-- post title --> <h2 class="p-name"> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> </h2> <!-- /post title --> <!-- post details --> <time datetime="<?php the_time('Y-m-j'); ?>" class="dt-published"><?php the_time('jS F Y'); ?></time> <!-- /post details --> <?php html5wp_summary('html5wp_index'); // Build your custom callback length in functions.php ?> <p><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="arrow-link">Read the full article</a></p> <?php edit_post_link(); ?> </article> <!-- /article --> <?php endwhile; ?> <?php else: ?> <!-- article --> <article> <h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2> </article> <!-- /article --> <?php endif; ?> 

EDIT

Contents of loop.php as requested in reply :)

<?php if (have_posts()): while (have_posts()) : the_post(); ?> <!-- article --> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <!-- post thumbnail --> <?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="h-entry__image-link"> <?php the_post_thumbnail(array(120,120)); // Declare pixel size you need inside the array ?> </a> <?php endif; ?> <!-- /post thumbnail --> <!-- post title --> <h2 class="p-name"> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> </h2> <!-- /post title --> <!-- post details --> <time datetime="<?php the_time('Y-m-j'); ?>" class="dt-published"><?php the_time('jS F Y'); ?></time> <!-- /post details --> <?php html5wp_summary('html5wp_index'); // Build your custom callback length in functions.php ?> <p><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="arrow-link">Read the full article</a></p> <?php edit_post_link(); ?> </article> <!-- /article --> <?php endwhile; ?> <?php else: ?> <!-- article --> <article> <h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2> </article> <!-- /article --> <?php endif; ?> 
Source Link

Loop on front-page.php

I'm trying to load the 3 latests posts on my homepage. I'm an utter novice but I seem to be making progress.

This is my code (below). At the minute each post has a title of "Home", I understand that is because the homepage is the main query?

<?php $latest_blog_posts = new WP_Query( array( 'posts_per_page' => 3 ) ); if ( $latest_blog_posts->have_posts() ) : while ( $latest_blog_posts->have_posts() ) : $latest_blog_posts->the_post(); get_template_part('loop'); endwhile; endif; ?> 

So how would I amend this code so it pulls in the 3 latest posts from the blog using loop.php?

I also having a Custom Post Type which uses a different page/loop. But I assume once this is working it would just be a matter of swapping the 'loop' for 'loop-2' to get that working using the same code?

Hope someone can help with this. It's one step forward, two steps back at the minute for me!