Woocommerce Show Single Product on Homepage
I am currently learning PHP & how to customize WordPress.
I have a shop that I set up on WordPress using the Woocommerce plugin. The shop holds only a single item. Since I only have 1 item to sell, I would like to show the product on my homepage in such a fashion where the complete product page is shown on the homepage.
Here is some code i’ve been trying to get to work (this is placed in the home.php file):
$prodpage = array(
'post_type' => 'product',
'posts_per_page' => 1,
'taxonomy' => 'banner',
'term' => 'banner'
);
$featured_query = new WP_Query( $prodpage );
if ($featured_query->have_posts()) :
while ($featured_query->have_posts()) :
$featured_query->the_post();
$product = get_product( $featured_query->product->ID );
// Product Info Output Here
endwhile;
endif;
wp_reset_query(); // Query Reset
I have also tried using query_posts in this manner:
if ( is_home() ) {
query_posts( 'p=31' );
}
The good news is that I don’t get flagged for any syntax errors. The bad news is that I am afraid my logic is off somewhere as I get a page with only the WP header and footer. The mid section where the product should show up is not showing up.
I really appreciate any guidance you guys are able to give! 🙂
Leave an answer
You must login or register to add a new answer .