Home › Forums › General Issues › woocommerce wc_get_template_part fetching page title instead of product title › Reply To: woocommerce wc_get_template_part fetching page title instead of product title
when you use setup_postdata() the variable name must be $post and it must be called in a way that affect the global $post.
If you are in a template that is loaded using get_template_part() then the global $post is already set up. If not the you must set it up using
global $post;
And you code needs to look like
$post = get_sub_field('selected_product');
setup_postdata($post);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.