我已经做了一些研究,并没有找到任何关于它。post_type如何获得1标题
我有4个不同的职位。
$args = array(
'post_type'=> 'post',
'order' => 'ASC');
$the_query = new WP_Query($args);
if($the_query->have_posts()) : while $the_query->have_posts()) : $the_query->the_post();
the_title();
endwhile;
endif;
wp_reset_postdata();
这段代码显示了所有titels,输出是这样的:
1post2post3post4post
1post2post3post4post
1post2post3post4post
1post2post3post4post
,但我想是这样的:
1post
2post
3post
4post
我如何获得呢?
编辑:@Vincent的帮助下做了一些改变。我如何获得这两部分代码来相互协作?
<?php
$args = array(
'post_type'=> 'cubeportfolio',
'order' => 'ASC'
);
$the_query = new WP_Query($args);
if($the_query->have_posts()) :
while ($the_query->have_posts()) : $the_query->the_post();
?>
<?php
the_permalink();
endwhile;
endif;
wp_reset_postdata();
?>
<?php
$args = array(
'post_type'=> 'post',
'order' => 'ASC'
);
$the_query = new WP_Query($args);
if($the_query->have_posts()) :
while ($the_query->have_posts()) : $the_query->the_post();
?>
<?php
echo get_the_title()."<br/>";
endwhile;
endif;
wp_reset_postdata();
?>
'the_title()。 '
';'是多种方式之一 – RiggsFolly
@RiggsFolly谢谢你,是的,我做到了,但就像我说的,我仍然有4个职位,我只想要1.我添加了我的洞代码,也许你明白了现在我正在尝试做的事 – di477