I’ve registered a custom post type, and that works without issue. My code to register is:
add_action( 'init', 'hvac_products' );
function hvac_products() {
register_post_type( 'hvac-products',
array(
'labels' => array(
'name' => 'HVAC Products',
'singular_name' => 'HVAC Product',
),
'description' => 'Add products to your main products page.',
'public' => true,
'menu_position' => 20,
'supports' => array( 'title', 'editor',)
));
}
Now that I’ve added a post, I’m trying to loop it into a custom template, and it is throwing a parse error. The code I’m using in my custom template is this:
<?
$loop = new WP_Query( array( 'post_type' => 'hvac-products', 'posts_per_page' => 10 ) );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<div class="products-container">';
echo '<div class="products-image">';
echo '<img src="';
the_field('product_image');
echo '" alt="<?php the_title();" ?></a></div>';
echo '<div class="products-text">';
echo '<h2 class="product-title">';
the_title();
echo '</h2>';
the_field('product_description');
echo '</div>';
echo '</div>';
echo '</div>';
echo '<div class="clear"></div>';
endwhile;
?>
I’ve attached a screen shot of the parse error. This is a fresh WP 3.6 install with the latest Roots. The only plugins I have active are ACF and Contact Form 7.
Any help greatly appreciated!