我正在尝试编写一个循环来按月显示帖子。到目前为止进展顺利,我只需要帮助从数据库中提取 post_content。我已经使用 wpdb 成功获取了所有其余的帖子信息。我已经尝试过 post_content 就像 post_title 一样,但它不起作用。
这是我正在处理的示例页面。 http://asg.websolutionshack.com/events/
<div id="events" class="full">`
<?php
$months = $wpdb->get_results("SELECT DISTINCT MONTH(post_date) AS month , YEAR(post_date) AS year FROM $wpdb->posts WHERE post_status = 'publish' and post_date <> now() and post_type = 'event' GROUP BY month, year ORDER BY post_date DESC");
$posts = $wpdb->get_results("SELECT id, post_title, post_content, MONTH(post_date) AS month , YEAR(post_date) AS year , DAY(post_date) AS day FROM $wpdb->posts WHERE post_status = 'publish' and post_type = 'event' ORDER BY post_date DESC");
foreach($months as $this_month){ ?>
<div class="month_block">
<h2 class="month"><?php echo date("F", mktime(0, 0, 0, $this_month->month, 1, $this_month->year)); ?> <?php //echo $this_month->year; ?></h2>
<?php for ($i = 0; $i <= count($posts); $i++){?>`
<div class="entry">
<?php if(($this_month->year == $posts[$i]->year)&&($this_month->month == $posts[$i]->month)){?>
<span><?php echo $posts[$i]->month ?>.<?php echo $posts[$i]->day ?>.<?php echo $posts[$i]->year ?></span><h3><?php echo $posts[$i]->post_title; ?></h3>
<p><<?php echo $posts[$i]->post_content; ?><a href="<?php echo get_permalink($posts[$i]->id); ?>">Details ></a></p>
<?php } ?>
</div><!-- entry -->
<?php } ?>
</div><!-- month -->
`
感谢您为我提供的任何见解。