Edit Wordpress Page Template - Best Practice

Hi,

I just wanted to ask what’s the best practice on the following:

I’ve created a Wordpress page template (whole landing page). I want to create several sites (for different cities) based on that page template.

What is the best way to define editable areas (manly text blocks) on the page in PG for Wordpress? I want to use alway the same layout but with different text on several parts of the page.

Thanks :v:

I tried the Customizer Field Smart Action. That works very well! Maybe this is the easiest and best way?

Hi @Riccarcharias,
Sorry, I started to compose a message earlier and didn’t send it! Yeah, I think that the Customizer is the best bet.
Cheers,
Bob

1 Like

Hi @RobM ,

I noticed that the Customizer always overwrites the text on all pages using the page template…

I want to create a site for town a, a site for town b and so on. I designed my page template for all towns and I want to write unique texts for each city. But when I edit the text on town a, it will also be changed on town b which uses the same page template (and vice versa).

I try to achieve something similar to PG Masterpages (page template) with editable areas for each page (I tried Customizer Field - Smart).

Did I miss a setting?

Hi @Riccarcharias,
I’m not sure how you set the customizer up. I would probably have to look at the project, or a good chunk of code to trouble-shoot this. Maybe you can share your project?
Sorry,
Bob

1 Like

Hi, @RobM

Here is a link to the theme and the Pinegrow-Project: Dropbox - Theme - Simplify your life

It’s about the page template stadtseite.html /.php. I want to edit the most text elements on each page using this template uniquely.

One code excerpt from a h2 using Customizer Field:

<h2 class="H1Title"><?php echo get_theme_mod( 'TitelH2', 'Schlüsseldienst <b>Open4u</b> <br/>in Essen' ); ?></h2>

Thanks @Riccarcharias,
I’ll take a look in just a little bit.
Cheers,
Bob

1 Like

Thank you, @RobM ! I can’t imagine that I’m the only one with the intension to create a page template with editable text for each page…

EDITED

Hi @Riccarcharias,
Now I get what you want a little better - sorry!
Yes, the customizer makes site-wide changes. Instead, you have a few choices depending on the amount of work you want to put in and how the pages will be used in the future. These are the best options I can see as someone who doesn’t do a lot of WordPress building anymore.

Choice -1 ( :grinning: Matjaz suggested this one after I posted the original)

This choice is the choice of the future!

Matjaz suggests that you create a block out of the whole page. In this case you would then add a ‘Block Attribute’ control for each element you want to edit. You wouldn’t export the page to your template, instead this block would then be added to an empty template. This actually makes a lot of sense and is probably easiest. I just don’t quite have my head wrapped around Blocks, yet.
If you need help with making blocks, check out this tutorial series by me (mostly the first two videos) or this one by Matjaz.

Choice 1

This choice is if these pages will essentially be static pages with no one but you editing.

Create a master page with editable areas. For each individual state create a child page and export as a custom template. So, ‘city1.php’, city2.php’, etc. Then on the WordPress side create individual pages using each of those template - no more editing after that. If you need to make changes you would need to edit the original project in Pinegrow, export, then re-upload the changed template.

Choice 2

This choice would be if you are adding your city pages once. It will allow you to edit the metadata fields later.

This one requires a bit more work. Each area to be edited needs to get a ‘Post Field - Smart’ action. So, replace out each of the customizer fields. Each one gets a unique field id. Once all of the field ids have been assigned you will need to add custom fields to the template for the metadata. Next, add a page using the template for each city. Then add in the meta data for each. To do this you need to make sure that the custom fields panel is turned on. It is in the options → Preferences in a page with Blocks activated:


Once that is turned on there will be a panel below your post editing area.
You need to create one name and value pair for each id on the page, so:

Those fields will be retained when saving, so if you need to edit in the future this only has to be done once per city page.

Choice 3

This choice would be if you will be adding new cities in the future, but it is a little more technical.

For this choice you will change your template with the ‘Post Field - Smart’ actions, as for choice 2. But then you will register the metadata fields so that they will appear automatically. This can most easily be done by using a plugin on the WordPress side. Pinegrow favors the use of ‘Advanced Custom Fields’, but there are other plugins. You can also add these fields programmatically. I can give you some pointers and links to tutorials, but I would only go down this route if you know PHP.

Hope this helps,
Bob

2 Likes

Hi @RobM , @matjaz ,

Thank you very much for this detailed help! That’s the reason I like the PG-Forum so much, thanks for taking so much time even on a Sunday!

I tried a few options and decided to go with the solution of Matjaz. Thanks a lot and hopefully others will find this post helpful in the future :heart:

Thanks,
Ric

1 Like