【发布时间】:2012-03-06 23:19:36
【问题描述】:
所以我现在有一种获取帖子的方式:
<?php
$args2 = array('post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID,
'order' => 'ASC');
?>
<?php $attachments2 = get_posts( $args2 ); ?>
<?php
if ($attachments2) { ?> ...do stuff...
但我需要做的只是收集 2012 年 3 月 1 日之后发布的帖子...
所以我不知道该怎么做 - 我被告知要执行一条 SQL 语句,但不知道从哪里开始。
你们会怎么做呢?
编辑:
下面是整个函数:
<?php
$args2 = array('post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID,
'order' => 'ASC');
?>
<?php $attachments2 = get_posts( $args2 ); ?>
<?php
if ($attachments2) { ?>
<h1 style='float:left'>Photos from the session</h1>
<?php foreach ( $attachments2 as $attachment ) { ?>
<?php if( $attachment->ID != $post_thumbnail_id){ ?>
<div style="width:100%; height:auto;">
<div style="float:left; width: auto; height:auto;">
<?php echo wp_get_attachment_image( $attachment->ID, 'full' ); ?>
<div style="width:auto; height:49px; background-color:#FFF; display:block; width:100%; float:left; margin-bottom:15px;"><div class="floatiefooterright"></div></div>
</div>
<?php $desc = apply_filters( 'the_content', $attachment->post_content );
if($desc != ''){ ?>
<div style="width:auto; height:auto; margin:10px; display:block; float:left;">
<hr class="contentseperator" />
<?php if($desc != ''){ ?>
<em><?php echo $desc ?></em>
<?php } ?>
</div>
<?php } ?>
</div>
<?php }; //end of the "if not featured image"?>
<?php }?>
<?php }?>
【问题讨论】: