Jul 11, 2021 7:41 AM - edited Apr 10, 2022 5:04 PM
i have created a template called thank-you.php and inside that i want to show different content as per the parent url.
for e.g. mywebsite.com /page/thank-you and mywebsite.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 on mywebsite.com/page, i need to show video related to /page on mywebsite.com/page/thank-you and the same procedure for mywebsite.com/another-page/thank-you which shows video related to /another-page.
Note: I need to show this as end result of hubspot form submission on different pages. Site
I am new to wordpress. any help is appreciated.
Solved! Go to Solution.
Jul 12, 2021 1:43 PM - edited Jul 12, 2021 1:50 PM
UPDATE - I just realized this quesiton is for WordPress and not HubSpot CMS. The logic is the same and just has to be written in PHP. https://stackoverflow.com/questions/7118823/check-if-url-has-certain-string-with-php
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 %}
Jul 12, 2021 1:43 PM - edited Jul 12, 2021 1:50 PM
UPDATE - I just realized this quesiton is for WordPress and not HubSpot CMS. The logic is the same and just has to be written in PHP. https://stackoverflow.com/questions/7118823/check-if-url-has-certain-string-with-php
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 %}
Jul 12, 2021 1:25 PM
@webdew , @BootstrapC , either of you able to assist here?