【发布时间】:2019-02-01 07:41:31
【问题描述】:
我正在创建一个自定义 WordPress 仪表板菜单,我想在那里显示帖子列表。我尝试在函数内使用循环显示,但出现错误:
Parse error: syntax error, unexpected '}'
这是我的代码:
function _submenu_cb() {
$args = array ( 'post_type' => 'product', 'post_status' => 'pubish' );
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) : $query->the_post();
echo '<h1>'.the_title().'</h1>';
}
}
如何解决这个问题?是否可以通过在函数内循环帖子来在自定义仪表板菜单中显示帖子列表?
【问题讨论】: