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! :)
‘banner’
and other occurrences with simple quotes'
.'term'
doesn't exist as parameter forWP_Query
, it should be'terms'
. Besides that, it should be part of a'tax_query'
; the'taxonomy'
parameter too. But because you only have and want one product there is no sense in that, you don't need it.