Try this bit of PHP:
<?php
$today = date('Ymd');
$query = new WP_Query("category_name=Event&m=$today");
if($query->have_posts()) :
?>
<ul><li><h2>Happening Today</h2>
<ul>
<?php while($query->have_posts()) : $query->the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
</li></ul>
<?php endif; ?>
Thanks Kafkaesqui.
I inserted the code in my sidebar and this is the error I get:
WordPress database error: [Not unique table/alias: 'wp_post2cat']<br />
SELECT DISTINCT * FROM wp_posts LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) LEFT JOIN wp_categories ON (wp_post2cat.category_id = wp_categories.cat_ID) LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) WHERE 1=1 AND YEAR(post_date)=2005 AND MONTH(post_date)=12 AND DAYOFMONTH(post_date)=14 AND (category_nicename = 'event') AND (post_date_gmt <= '2005-12-14 06:42:59' OR id IN (-1,3,5,7,8,9,45,46,56,82,84,85,87,89,90,91,93,94,95,96,97,98,99,100,101,104) ) AND (post_status = "publish" OR post_author = 1 AND post_status != 'draft' AND post_status != 'static') AND (category_id = 7 OR category_id = 8) GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 0, 3
Does it make sense to you?
OK – so I *think* it is because I am calling 2 loops in one page? I have been staring and staring at The Loop page in the codex but I just can not make sense of it.
The code works brilliantly in a page all by itself, and perfectly in the sidebar as long as there is nothing very exciting going on in the main page. So thanks for that Kafkaesqui. I feel as if I am making progress if only in that I have figured out what I am not smart enough to figure out on my own. Thanks in advance for any help anyone continues to offer; I have a feeling that I am on the verge of learning something VERY important with regard to WP…
OK – I am sorry to say that I never got this working when there is a loop already called. No matter what I try it still throws the same error. Can somebody shed a little more light on this for me? Again, Kafkaesqui’s code works like a charm (thanks K!), except in my sidebar when there is another loop present.
Much gratitude in advance.