我正在学习WordPress。我正在学习“如何在WP中创建和显示自定义帖子”。我正在使用插件调用“自定义帖子类型UI”。通过这个插件,我添加了一个名为Project Feature的新自定义帖子和post_type project_feature。 Ot有标题,缩略图和描述区域。
在我的php文件中,我编写了以下代码来显示:
<?php
$loop = new WP_Query(array('post_type' => 'project_feature', 'orderby' => 'post_id', 'order' => 'ASC'));
?>
<?php
while($loop->have_post()):$loop->the_post();
?>
<div class="col-sm-4">
<?php
if(has_post_thumbnail())
{
the_post_thumbnail();
}
?>
<h3><?php the_title(); ?></h3>
<p class="black_text"><?php the_content(); ?></p>
</div> <!-- col -->
<?php endwhile; ?>
但这不起作用。你能帮我理解我做错了什么吗?
先谢谢... :-)
答案 0 :(得分:0)
我认为你已经做了所有正确的事,但在
$loop = new WP_Query(array('post_type' => 'project_feature', 'orderby' => 'post_id', 'oider' => 'ASC'));
'oider' => 'ASC' might be 'order' => 'ASC'
答案 1 :(得分:0)
$args = array(
'post_type' => 'project_feature',
'orderby' => 'post_id',
'order' => 'ASC'
);
$query = new WP_Query($args);
/* print $query and see in what parameters are you getting data, eg., i got data in post_title */
while ($query->have_posts()) : $query->the_post();
$thisisid = get_post($post->ID);
echo $thisisid->post_title;
endwhile;