我會盡力解釋一下。我有醫生頁面,并且有一個自定義模板,因此他們可以創建一個頁面并向其添加數據,它將顯示在模板頁面中。但現在我需要一份所有醫生的名單。所以我需要獲取醫生的所有頁面并排除網站頁面。我嘗試了這個,但我只得到當前頁面的標題。 <?php if ( have_posts() ) { while ( have_posts() ) { the_post(); // the_title(); the_content(); // } // end while } // end if ?>這可能嗎?如果是的話,又是怎樣的呢?
2 回答

慕勒3428872
TA貢獻1848條經驗 獲得超6個贊
這是您最后一條評論的答案:(未經測試)
<?php $args = array(
'role' => 'subscriber',
// If custom role exist, replace "subscriber" by custom role
// More on roles @: https://wordpress.org/support/article/roles-and-capabilities/#roles
'order' => 'ASC'
);
$users = get_users( $args );
echo '<ul>';
foreach ( $users as $user ) {
echo '<li>' . esc_html( $user->display_name ) . '</li>';
}
echo '</ul>'; ?>
- 2 回答
- 0 關注
- 149 瀏覽
添加回答
舉報
0/150
提交
取消