我有一个名为“Events”的自定义帖子类型。帖子显示正常,但WP查询循环只显示一个帖子而不是所有帖子。以下是来自events.php文件的完整代码:
void MemoryManagedClass::operator delete ( pointer objectPointer ) noexcept
{
i64 allocatorAddress = *reinterpret_cast<i64*>( DATA( objectPointer ) - sizeof( i64 ) );
MemoryAllocator* memoryAllocator = reinterpret_cast<MemoryAllocator*>( allocatorAddress );
memoryAllocator->Free( DATA( objectPointer ) - sizeof( i64 ) );
}
我在这里遗漏了什么吗?
答案 0 :(得分:2)
您的元查询错误(这个错误很容易发生,我自己做了一次)。如果你正在做'meta_query',你必须在数组中创建数组,每个数组用于一个meta参数。请参阅以下代码:
$events = new WP_query(array(
'post_type' => 'events',
'posts_per_page' => -1,
'order' => 'ASC',
'orderby' => 'meta_value',
'meta_key' => 'min_event-start',
'meta_query' => array( array(
'key' => 'min_event-start',
'value' => date('Y-m-d'),
'compare' => '>',
))
));
有关食典委的更多信息:https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters