You need to explode the comma separated string to get the array of IDs. Follow the below code.
$cookie_array = $_COOKIE["your-results"];
// Test output
echo $cookie_array;
$cookie_array = array_map( 'absint', (array) explode(',', $cookie_array) );
$sug_args = array(
'post_type' => 'product',
'post__in' => $cookie_array,
);
$sug_query = new WP_query ($sug_args);
if( $sug_query->have_posts() ) :
while( $sug_query->have_posts() ) :
$sug_query->the_post();
// Run Loop
wc_get_template_part( 'content', 'product' );
endwhile;
endif;
wp_reset_query();
Related Posts:
- retrieve thumbnail from post ID of best selling product in category
- WP_Query | Help me create a search term with an ‘OR’ relation?
- Display related products with custom output
- How can I use wp_query to show all product data using just the products ID?
- Display a specific category of products in shop page and disable code for specific actions
- How to store post ID’s in cookie or session to display the same posts later
- How to display SQL query that ran in WC_Order_Query?
- WP_Query multiple post results
- WordPress WP_Query without query GET parameters
- Output product category link from WP_Query
- How to work Woocommerce pagination inside shortcode?
- WP_Query for woocommerce products with a pattern as a post_title
- IF statement not working – Any suggestions?
- get_filtered_term_product_counts – Get product terms if any products
- WP_Query To Display Product Of Brand On Taxonomy Page
- Woocommerce Related Product by 2 taxonomy
- wp_query beginner
- WooCommerce – Print Processing orders [closed]
- Use WP_Query Data In Cookie
- Ajax Load More or View More functionality for woocommerce category layout by template overriding
- How to correctly add Javascript in functions.php
- How to set custom cookies before output
- Display message once per session to users with a specific role
- Alter secondary loop to exclude posts from current page category
- How to prevent those PHP variables from being cached on WordPress?
- Setting All Drafts to ‘exclude-from-catalog’ in WooCommerce
- How to query for pages/post depending on slug?
- How do you add customer capability after Woocommerce purchase?
- Change sign up fee in cart for subscription products WooCommerce
- Make the first item as default on Woocommerce product category items list
- Setting a cookie upon specific URL visit
- WordPress custom slug (endpoint) and compare all links
- wp_query with cat not working
- Recent Posts slider, using WP_Query(), loads duplicate sliders
- Compare post-IDs within WP_Query? (Less than / Greater than)
- How to use $query->set with post__in?
- dividing sub-categories by parent category – WordPress
- Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
- I want to add custom add to cart link [closed]
- get_posts() and WP_query limits ‘AND’ conditions to a maximum of 6 for meta value queries in WordPress
- Custom query, checking values of multiple meta keys
- How do I remove the product thumbnail link from a specific div in Woocommerce? [closed]
- Redirect to another page using contact form 7? [closed]
- Can a plugin redirect product page based on IF condition?
- WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
- Array to string conversion on array_map
- Target post_date_gmt if it’s empty or not set
- Remove page title in product page using a function
- woocommerce specific quantities for product
- Get all posts as an array ID => Name
- woocommerce related product title length
- Passing an array into WP_Query as a variable
- Custom query vars filters problem with pagination
- Do not duplicate posts with multiple categories in multiple loops
- Woocommerce custom Plugin in wordpress [closed]
- Displaying Event within two given time frames
- Set cookie for visitor
- Remove Post if Advanced Custom Field is checked to fix paging
- How to separate product payment and shipping payment in WooCommerce checkout? [closed]
- Search AJAX Filters – Multiple Query Loops Into One Loop (Optimization)
- WP_Query: How to get results from both meta_key options?
- How to get woocommerce orders with get_posts method in a shortcode
- Passing in MySQL prepare statement parameter separately throwing error
- Woocommerce disable order item link (backend) [closed]
- Set all WooCommerce Products to Simple, Virtual & Downloadable
- Fatal error login WordPress [duplicate]
- Load more posts using AJAX based on posts inside WP_Query
- Undefined array key 0 wp-includes/capabilities.php on line 76
- How do I know if the user is a customer?
- How to select post ID for given parent name with nested prepared queries?
- I want to fusion the product columns in email table order
- posts_per_page displays only 2 posts instead of 4 posts
- WooCommerce is_product_category() not working
- How do I programmatically add ‘reviews_allowed’ to WooCommerce product?
- Need to show 7 posts from actual date
- Add code to the header of posts by particular author
- Paged WP_Query is quitting on page 3
- Adding product permalink on admin order page throwing error
- Get Child of Child Pages in custom Menu
- How to override WooCommerce Order Item Meta with data from Cart?
- How can i style “echo apply_filters”
- Meta query not showing result properly
- Get all woocommerce product names with price and show using core php
- How to properly create multiple conditions to redirect users roles to different pages
- Help on Wp_query to print an term
- How can i put php code on the wordpress page?
- making a search.php query
- How do I prevent a folder from reappearing in my home directory?
- jQuery doesn’t work in my php snippet
- Query seems to be duplicated
- How to add custom checkout field in user details mail template
- Add specific phrase after every product title including the discounted price? [closed]
- Pagination in category.php not functioning
- Display Sale Price Before Regular Price (WooCommerce)
- WooCommerce – Show ‘Sales’ badge on variable products where only some variations have sales price [closed]
- How to create a container in php then customise it in CSS
- Woocommerce Convert existing order to the cart
- How to change shipping method title based on cart amount?
- Product Search in search.php
- using custom pages for myaccount in woocommerce