hi all,
i’m working on setting unique social sharing images for individual pages and products.
i have successfully done that by adding page and product image url metafields > adding custom code in the dawn theme.liquid to get the image selected for social sharing. however, i noticed the page social sharing image goes back to the default set in online store > preference after i added the custom code for products.
here are the changes i made in chronological order:
- added custom coding for unique social sharing images for individual pages
- unique social sharing images for individual pages confirmed to be working when checking on whatsapp
- added custom coding for unique social sharing images for products
- unique social sharing images for products are working, but social sharing images for pages have reverted back to the default set in online store > preference when checking on whatsapp
- added conditional logic to the code to to check the template rendered on page load and get the correct image, but it’s not working
attached is the code i’m using in the dawn theme liquid with the conditional logic. i have checked with shopify support that the template values are correct.
{% if template == 'product' %}
{% if product.metafields.product_data.og_image %}
{% else %}
{% endif %}
{% elsif template == 'page' %}
{% if page.metafields.custom.og_image %}
{% else %}
{% endif %}
{% endif %}
appreciate any help i can get on this. thank you