If you want to use the Wp_Query
for selecting the single product from the database you have to pass the p
in the $args
so that if fetches the data and the post_type
should be as product
.
Follow up the Normal
$args
method along with that you have to add the following lines of code.
<?php
$params = array(
'p' => 'YOUR PRODUCT ID', id of a page, post, or custom type
'post_type' => 'product'
);
$wc_query = new WP_Query($params);
?>
<?php if ($wc_query->have_posts()) : ?>
<?php while ($wc_query->have_posts()) : $wc_query->the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p><?php _e( 'No Product' ); ?></p>
<?php endif; ?>
Related Posts:
- Getting the gallery images from products in woocommerce?
- add_filter to modify woocommerce_cart_item_name hyperlink
- Get product details by url key in WordPress woocommerce
- How to get rid of the hover zoom in WooCommerce single products
- How do I display certain products via their category on a section of a page using PHP?
- Display orders instead of woocommerce my account dashboard for logged in users [closed]
- Programmatically change Payment Methods WooCommerce
- pre_get_posts with WooCommerce Shortcode Query
- Reverse engineering of WooCommerce Storefront filters
- Use WooCommerce function in other WordPress plugin
- How to remove recurring totals information for a particular subscription product? [closed]
- WordPress codex: apply_filters – clarification on creating a new hook on the fly. How do we use it?
- Add product description (content) to WooCommerce customer processing order email
- Woocommerce – disable «place order» until user checks Privacy Policy
- Calling calculate_shipping() with ajax in woocommerce
- Adding product SKU before cart item name in WooCommerce
- Accessing parameters when adding filter
- Remove checkout fields with Woocommerce depending on one of several shipping methods
- Replace one coupon to another after coupon added
- WooCommerce Multi-Currency shortcode not working
- Filter WooCommerce Orders query with user meta data
- Child theme dosn’t overwrite WooCommerce (version 3.4.7)
- rating, share and review issue for single WooCommerce page
- Delete All Product Images in phpmyadmin
- How to add a custom text for order confirmation email template woocommerce
- I want to get the value of a select attribute in the checkout page, and then use it to show or not the delivery data
- woocomerce is serving OR Relation instead of AND on taxonomy product_tag
- Display Advanced Custom Fields value in Woocommerce admin order details
- Some images aren’t shown on wordpress after installation on host
- How to display text between product thumbnail and CTA button on WooCommerce “Shop” page
- Multiple archive product exist
- WordPress & WooCommerce: Localhost, Staging and production environments and how to sync them without losing data
- PayPal Express on product page in WooCommerce – doesn’t seem to work on product page?
- Woocommerce – Want to block a user agent from accessing specific product pages
- Reset all stock status in woocommerce
- How to – proper WordPress 301 redirects?
- Additional fields on Woocommerce’s rating system
- Woocommerce product image [closed]
- Question on WooCommerce Syntax
- woocommerce_new_product action doesn’t fire
- Change The Woocommerce Product Categories Dropdown Widget Placeholder Text
- how to create additional button on single product page
- minimum order item for certain products exempting 2 other products (in bulk)
- Is it possible to checkout with 2 different shipping options on a single order? [closed]
- Sender e-mail address, for new order email to customer, is suddenly wrong [closed]
- Pass class to Woocommerce shortcode [relative_products] [closed]
- Woocommerce product editor does not add br
- Undo WooCommerce CSV import
- A Woo commerce extension has deleted my old theme.How to undo? [closed]
- How can I remove a WooCommerce Product Tab’s sub section in wp-admin?
- is_shop doesn’t work for woocommerce [closed]
- Woocommerce Advanced Shipping (WAS) condition is not being called when selecting “Ship to different address” [closed]
- Strip string from $_product->get_title() to get a cleaner mini-cart
- Product page attributes dropdown show price
- Smart Design for Blog + Woocommerce + LearnDash + Forum/Bodyboss
- Ajax add to cart not updating Elementor mini cart totals
- I want to store user password (during registration) in an other table in the same database in addition to the user table MD5 Hash
- How to edit the default woo-commerce Store page meta title tag “Products”
- Unable to add product to the cart
- Custom Email via Hook only for completed order
- Woocommerce : Add name filed of checkout page to buyers wordpress display name
- Need help with woocommerce roles
- Change WooCommerce product and variation prices programatically without affecting performance
- Help to locate a woocommerce hook method
- woocommerce_product_quick_edit_save hook not fired
- Changing Title Tag on Shop Archive Page (current solution reverting to Title of First Product in Loop)
- WooCommerce return 404 in the product page
- What is the meta_key for woocommerce discount amount?
- Why does wc_get_products($arg) return no products when $arg = ‘average_rating’ => 5.0
- Query product’s image path by category WooCommerce database?
- Delete comma in front of currency woocommerce
- Not displaying Category and subcategory from woocommerce Pluign
- Collapsible product categories on sidebar?
- How update price for variable product
- currentURL is not defined
- Adding a second button next to the shop button Woocommerc [closed]
- Add button linked to single product page on order detail page
- Woocommerce REST API not considering discounts and coupons
- Multiple sorting criteries (order by)
- Woocommerce Order Reports MYSQL
- syntax error – woocommerce
- How to on/off woocommerce filter with redux framework [closed]
- Cross-sells on WooCommerce product page
- Admin Order adding an extra product on add_line_item
- Get WP All Export row ID
- Is it possible Different templates of products for specific category in WooCommerce?
- WooCommerce: Conditional Tag for Wishlist Page
- WooCommerce – missing products when viewed by tag
- Hide woocommerce login form
- Decrease stock quantity when a variation is sold using Woocommerce
- WooCommerce show decimals in totals [closed]
- Woocommerce Mandatory Field on Shipping Details [closed]
- Create a shortcode to show product tag name on tag archive
- Send data to external websites when there is an update or create a post
- Add a custom code with custom link after add to cart for every product
- WooCommerce product permalink based on product’s current category
- Disable duplicate WC product category URLs
- how should i get products based on tags in woocommerce
- Add custom text to product category page
- Woocommerce permalink URL change in DB