# load common template with different content for different pages in wordpress

**URL:** <https://community.hubspot.com/t/load-common-template-with-different-content-for-different-pages-in-wordpress/40480>\
**Category:** CMS Development\
**Tags:** professional\
**Created:** [July 11, 2021, 11:41am UTC](https://community.hubspot.com/t/load-common-template-with-different-content-for-different-pages-in-wordpress/40480 "2021-07-11T11:41:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aqibjaved](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/aqibjaved/32/13521_2.png) [@Aqibjaved](https://community.hubspot.com/u/Aqibjaved)\
**Post date:** [July 11, 2021, 11:41am UTC](https://community.hubspot.com/t/load-common-template-with-different-content-for-different-pages-in-wordpress/40480/1 "2021-07-11T11:41:53Z")

</div>

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](http://mywebsite.com) /page/thank-you and [mywebsite.com](http://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](http://mywebsite.com/page), i need to show video related to /page on [mywebsite.com](http://mywebsite.com/page/thank-you) and the same procedure for [mywebsite.com](http://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

]([https://deepmaterialkr.com/](https://deepmaterialkr.com/))

1. do i need to create a page in admin area for that? [

unionwells vietnam

]([https://www.unionwellvietnam.com](https://www.unionwellvietnam.com))

1. 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)?
2. how can i solve this problem?

I am new to wordpress. any help is appreciated.

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [July 12, 2021, 5:25pm UTC](https://community.hubspot.com/t/load-common-template-with-different-content-for-different-pages-in-wordpress/40480/2 "2021-07-12T17:25:28Z")

</div>

[@webdew](https://community.hubspot.com/t5/user/viewprofilepage/user-id/131510) , [@Jake\_Lett](https://community.hubspot.com/t5/user/viewprofilepage/user-id/72866) , either of you able to assist here?

---

<div class="post-metadata">

**Author:** ![Jake\_Lett](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jake_lett/32/45178_2.png) [@Jake\_Lett](https://community.hubspot.com/u/Jake_Lett)\
**Post date:** [July 12, 2021, 5:43pm UTC](https://community.hubspot.com/t/load-common-template-with-different-content-for-different-pages-in-wordpress/40480/3 "2021-07-12T17:43:58Z")

</div>

**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](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.

```lia-code-sample
{% 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 %}

```
