guitarcrazy087
Member
Posted 7 months ago #
Okay so here's my problem. I have a side bar on the left in my header.php file. In this side bar I would like to display the title and date of my most recent post, no matter what is being displayed in the body of the site. i.e. a "page", a post from years ago, even the most recent post itself.
I am new to editing the PHP of Wordpress and all my attempts at this have failed. I have searched through the codex and found nothing that has worked so far.
Any help is appreciated!
Thanks!
Joe
guitarcrazy087
Member
Posted 7 months ago #
Okay, I found a way to do it. I did this:
$my_query = new WP_Query('showposts=1');
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID;
$title = "the_title()";
echo $title;
endwhile;
wp_reset_query();
That's what I used for the first part. The other part still works.
Thanks for the suggestion.
I have one other question though: how do I capture the output of the_title() in a variable without it printing onto the page?
Thanks!