WordPress is not installed on the dev server I linked to, but I’m calling the “wp-blog-header.php” from our live server where WP is installed at the top of the page.
Let me post the code here so I can offer more detailed as to what my issue is (see below). The first div is getting the recent post properly. However, when I try to use the same code in the second div, it causes a 500 error and I’m not sure how to use multiple loops (I tried reading the WP documentation but couldn’t quite grasp it).
<div class="col-md-6">
<article>
<?php
global $post;
$args = array( 'posts_per_page' => 1 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post);
?>
<div class="date">
<span class="day"><?php the_time('jS'); ?></span>
<span class="month"><?php the_time('M, Y'); ?></span>
</div>
<h4>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a><br />
<?php endforeach; ?>
</h4>
<p>
<?php
the_excerpt_max_charlength(140);
function the_excerpt_max_charlength($charlength) {
$excerpt = get_the_excerpt();
$charlength++;
if ( mb_strlen( $excerpt ) > $charlength ) {
$subex = mb_substr( $excerpt, 0, $charlength - 5 );
$exwords = explode( ' ', $subex );
$excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
if ( $excut < 0 ) {
echo mb_substr( $subex, 0, $excut );
} else {
echo $subex;
}
echo '...';
} else {
echo $excerpt;
}
}
?>
</p>
</article>
</div>
<div class="col-md-6">
<article>
<div class="date">
<span class="day">15</span>
<span class="month">Jan</span>
</div>
<h4><a href="blog-post.html">Lorem ipsum dolor</a></h4>
</article>
</div>