I’m using this music widget on my shopify and received a code to edit the theme liquid. I only want the widget to appear on one specific page. I used {% if template.name == ‘page’%} “insert widget code here” {% endif %} but the widget shows up on all pages and interferes with the experience. Am I able to specify which page name it shows up on. Please let me know. Thank you!
Hi @yayamusic2270 , you can use below code
{% if page.handle contains “music-page-url” %}
“insert widget code”
{% endif %}
if above code is not work then you can use this -
{% if page.handle == “music-page-url” %}
“insert widget code”
{% endif %}
Thanks
Hello @yayamusic2270 ,
That’s a great idea; allow us to help you achieve this. Here is the solution you are looking for.
We are providing the correct code for your help. Please use this and see if it works.
{% if page.title==“music-page-title” %}
add Code here (widget)
{%endif%}
{% if page.handle contains “music-page-url” %}
add code here (widget)
{% endif %}
{% if page.handle == “music-page-url” %}
Add code here (widget)
{% endif %}
Let us know if you need more help with this.
Regards,
CedCommerce
If you only want the music player to appear on a single Shopify page, you’ll need to embed the player script directly inside that page’s custom HTML section rather than adding it to the theme files. That way it won’t load globally across the site.
I recently dealt with something similar while testing audio features for a project related to black hole music download, so having page-specific code placement made a big difference. Keeping scripts isolated really helps avoid layout conflicts.
Hi @yayamusic2270
May be you can try this:
Online store > Pages > Your specific page > Go to specific page > Find “Show HTML” in the toolbar below the content section.
Paste the “widget code” where you want to place it. Hope this helps.