我有一个响应儿童主题,我正在写一个插件列出使用响应网格的帖子。WP_Query奇怪的行为与秩序ASC
如果我将命令设置为DESC(在WP_Query中),一切正常,但对于ASC,我遇到了一个非常奇怪的行为。发布后,按升序排列,但我的函数获取后缩略图不再有效。它与DESC一起工作... wp查询如何影响我的功能?!?!?!
这些都是工作的简码:
[myplugin category="0" order="DESC" orderby="date" limit="4"]
[myplugin category="0" orderby="date" limit="4"]
,这一次没有:
[myplugin category="0" order="ASC" orderby="date" post_not_in="233" limit="4"]
这是我用它来获得在后的第一图像的功能:
function my_get_first_image($postID) {
$args = array(
'numberposts' => 1,
'post_mime_type' => 'image',
'post_parent' => $postID,
'post_status' => null,
'post_type' => 'attachment',
);
$attachments = get_children($args);
if ($attachments) {
foreach ($attachments as $attachment) {
$fullImg = wp_get_attachment_url($attachment->ID, 'full');
$image_attributes = wp_get_attachment_image_src($attachment->ID, 'big') ? wp_get_attachment_image_src($attachment->ID, 'big') : $fullImg;
return '<a rel="shadowbox" href="'.$fullImg.'"><img class="nw_front_thumb" src="' . wp_get_attachment_thumb_url($attachment->ID) . '" class="current"></a>';
}
}
return '';
}
循环有点长,所以我把它粘贴在粘贴文件夹中。正如你可能想通了这个代码是在我的插件:
编辑: http://pastebin.com/rw6NWEeV
请张贴循环,好像你有一个奇怪的怪癖 – 2013-03-31 16:19:28
现在我没有访问到文件...将在本傍晚或最坏情况明天。 – user568021 2013-03-31 17:09:52
这里是...我希望这是有道理的.. – user568021 2013-04-01 20:25:00