I'm trying to use WP_Query in function.php to display a custom post type on a certain page.
I just can't seem to get it to work, can anyone see issues with my code? nothing is output at all and there are apparently no errors.
/*** add venues to venue page ***/
add_action( 'woo_post_inside_after', 'venue_loop' );
function venue_loop() {
if ( is_page(123) ) {
$args = array(
'post_type' => 'tribe_venue',
'orderby' => 'title',
'order' => 'DESC',
'posts_per_page' => 10
);
$venue_posts = new WP_Query($args);
if ( $venue_posts->have_posts() ) {
while( $venue_posts->have_posts() ) {
$venue_posts->the_post();
$output .= '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
}
}
return $output;
}
}