I'm creating a custom WordPress dashboard menu and I want to display post list there. I try to display with loop inside a function, but getting error:
Parse error: syntax error, unexpected '}'
Here is my code:
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>';
}
}
How to fix this?. Is it possible to display the post list in custom dashboard menu by looping the post inside a function?