<?php
$the_query = new WP_Query(array(
'post_type' => 'needs',
'orderby' => 'date',
'category_name' => 'volunteers', //name of category by slug
'order' => 'DESC',
'posts_per_page' => '5')); // how many posts to show
// Put into the loop
while ($the_query->have_posts()) :
$the_query->the_post();
echo '<tr><td>' . get_the_date() . '</td>';
echo '<td>' . get_the_title() . '</a></td></tr>';
endwhile;
// Restore original Post Data if needed
wp_reset_postdata(); ?>
나는이 코드를 사용하여 자원 봉사자 범주에서 필요성의 제목과 날짜를 정확하게 표시합니다. 게시물 자체에 링크 할 제목이 필요하지만이 코드로 퍼머 링크를 사용할 수 없습니다. 아이디어가 있으십니까?제목 자체를 클릭 할 수있게하십시오. (Wordpress)
이것은 맞습니다. 또 다른 방법은 다음과 같습니다. echo '
다행 당신을 위해 일했다! get_the_ID()는 단순히 $ post 변수에서 ID를 가져 오는 함수이므로 차이가 없습니다. $ post-> ID는 동일한 ID를 얻는보다 적절하고 직접적인 방법이며 더 자주 볼 수 있습니다. – jrobson153