CMS Development

Aqibjaved
Membre

load common template with different content for different pages in wordpress

Résolue

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

  1. do i need to create a page in admin area for that? unionwells vietnam
  2. do i need to set this page as a child? if so, how can i set as a child for specific pages(around 25 pages)?
  3. how can i solve this problem?

I am new to wordpress. any help is appreciated.

0 Votes
1 Solution acceptée
Jake_Lett
Solution
Guide | Partenaire solutions
Guide | Partenaire solutions

load common template with different content for different pages in wordpress

Résolue

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 %}

 

  

Voir la solution dans l'envoi d'origine

2 Réponses
Jake_Lett
Solution
Guide | Partenaire solutions
Guide | Partenaire solutions

load common template with different content for different pages in wordpress

Résolue

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 %}

 

  

dennisedson
Équipe de développement de HubSpot
Équipe de développement de HubSpot

load common template with different content for different pages in wordpress

Résolue

@webdew , @Jake_Lett , either of you able to assist here?

0 Votes