jul 11, 20217:41 AM - editado abr 10, 20225:04 PM
Membro
load common template with different content for different pages in wordpress
resolver
i have created a template calledthank-you.phpand inside that i want to show different content as per the parent url. for e.g.mywebsite.com /page/thank-youandmywebsite.com/another-page/thank-you. here, i need to load same template but with different content as per the parent url. let's say if i submit the form onmywebsite.com/page, i need to show video related to/pageonmywebsite.com/page/thank-youand the same procedure formywebsite.com/another-page/thank-youwhich shows video related to/another-page. Note: I need to show this as end result ofhubspotform submission on different pages. Site
I haven't tested this out but I think should do what you want. Edit your thank-you.php with this code and update the strings you want to match with your unique page names. This will allow you to have one template with content swapped by the url.
{% if page_meta.canonical_url is string_containing "/page1/" %}
<h1>Page 1 content</h1>
{% elif page_meta.canonical_url is string_containing "/page2/" %}
<h1>Page 2 content</h1>
{% else %}
<h1>Default content</h1>
{% endif %}
I haven't tested this out but I think should do what you want. Edit your thank-you.php with this code and update the strings you want to match with your unique page names. This will allow you to have one template with content swapped by the url.
{% if page_meta.canonical_url is string_containing "/page1/" %}
<h1>Page 1 content</h1>
{% elif page_meta.canonical_url is string_containing "/page2/" %}
<h1>Page 2 content</h1>
{% else %}
<h1>Default content</h1>
{% endif %}