First recent post missing on custom 404 page


Moving the global variable out of the loop works.

function recent_posts_grid() {

  // Get latest posts
  $custom_posts = get_posts( array( 'numberposts' => 6 ) );

  // Remove post meta
  beans_remove_action( 'beans_post_meta' );

  // Add responsive grid
  ?><div id="recent-posts-grid" class="uk-grid uk-grid-match" data-uk-grid-margin=""><?php

  // Global variable 
  global $post;

  // Add posts
  foreach ( $custom_posts as $post ) {

    // Setup the postdata.
    setup_postdata( $post );
    ?><div class="uk-width-large-1-3 uk-width-medium-1-2">
    <article class="uk-article uk-panel-box"><?php

    // Add post image and title
    beans_post_image();
    beans_post_title();

    ?></article></div><?php

  }

  ?></div><?php

}

Write a reply

Login or register to write a reply, it's free!