I'm developing a home page that is a mishmash of a bunch of information, including a random smattering of several categories, including blog posts (category 192 in the code below)
I'm obviously not invoking the standard WP loop to do this. Is there a way to get the date and author to echo properly:
<!-- RANDOM BLOG POST INSERTION --> <?php $rand_posts = get_posts('cat=192&numberposts=2&orderby=rand'); foreach( $rand_posts as $post ) : ?> <div class="box tall blogBox"> <h2>Blog <span>| <?php the_date('m/d/Y'); ?></span></h2> <a href="<?php the_permalink() ?>"><img src="<?php the_field('01HomeThumbnail'); ?>" alt="<?php the_title(); ?>" width="113" height="111" /></a> <h3>by <?php the_author(); ?></h3> <h4><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h4> <a target="_blank" href="<?php the_permalink() ?>" class="readPost">Read Post</a> </div> <?php endforeach; ?>
The two issues I'm experiencing I think are both because I'm outside of the loop, but unfortunately, I'm not sure how to get the info I need.
Basically, I am randomize 2 blog posts. Everything outputs as expected, except the date and the author. I know
<?php the_author(); ?> is deprecated, but it's not returning the expected author anyway. The other thing not working is
the_date. It seems to output on the first outputted blog post, but subsequent are blank.
Any help would be appreciated on either of these.
I'm building this on a custom theme based on the twenty ten theme.