我已經做了一些研究,並沒有找到任何關於它。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