Home Forums General Issues Post Object (multiple instances)


Post Object (multiple instances)

  • I’m having issues with Post Objects. I have a Product Details section setup for my custom post type using the ACF plugin. I have one Post Object setup called Special Product. The Post Object uses a select field to choose from the list of Products. I use the ID to pull the Product’s URL and link a button on the page. Further down in the Product Details I have another Post Object setup called Related Product 1. This also uses a select field to choose from the list of Products. Again I use the ID, this time I pull the URL, title and thumbnail.

    On a couple products I have the Special Product and the Related Product 1 both using the same Product. This is causing an issue when I view the product page. Only one of the spots is being generated correctly (Special Product). The Related Product 1 section is lower on the page and isn’t being generated correctly. Instead of using the ID of the product I selected it’s pulling the ID of the current product page I’m viewing.

    Any ideas why this would be happening? If I change the Special Product to use a different product, the Related Product 1 will display the correct product chosen. I’ve at least got it narrowed down what two fields are causing the problem. Shouldn’t the plugin allow you to use multiple Post Objects and those Post Objects could have the same value?


  • Hi @csnodgr2

    Have you debugged your code to check exactly what ACF is returning from the get_field calls?


  • The ACF is returning the correct calls when both the Post Objects aren’t using the same product. When both are using the same product the first (Special Link) uses the correct product, while the second Post Object (Related Product 1) doesn’t call the correct product (although the correct one is selected and showing as selected on the ACF form).

  • Hi @csnodgr2,

    When both post types are using the same product, what does Related-Product-1 return? A different product?


  • Yes I have (Special Link) Post Object set to product “Full Custom Design Faces”. I then have (Related Product 1) Post Object also set to “Full Custom Design Faces”. However, when I view the product page the Special Link is correct and linking to Full Custom Design Faces product page, but the Related Product 1 is showing me 1 Color Custom Design Back product. If I change (Special Link) Post Object to be a different product and leave (Related Product 1) Post Object to “Full Custom Design Faces” then the Special Link correctly links to that different product and the Related Product 1 then shows the “Full Custom Design Faces” product info.

    It’s really strange that when those two Post Objects use the same product they don’t display the correct info.

  • I figured out that a combination of some if statements in my code was causing the issue. Thanks for the help.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Post Object (multiple instances)’ is closed to new replies.