I'm creating a short code to display a table based on a custom post type. For some reason this is creating an infinite loop. Here is the code for the shortcode
function cwf_enquiry_table_html()
{
$args = array(
'post_type' => 'form-enquiry'
);
$form_enquiries = new WP_Query($args);
if($form_enquiries->have_posts())
{
while($form_enquiries->have_posts())
{
echo '<p>' . get_the_title() . '</p>';
}
}
// wp_reset_query();
}
add_shortcode('enquiry_table', 'cwf_enquiry_table_html');
Currently this is just returning "Home" constantly. I've got the shortcode on the home page so I presume it's pulling some other query and not the one I am trying to run. As you can see I tried to reset the query but it didn't fix anything.