简体   繁体   English

更改不同页面的自定义模板的内容-Wordpress

[英]Change content of a custom template for different pages - Wordpress

I'm not too familiar with Wordpress, however I've been asked to use it for a website I'm building as the client would like the ability to add pages later on for certain events that may need to be created. 我对Wordpress不太熟悉,但是有人要求我将它用于我正在构建的网站上,因为客户端希望以后可以为可能需要创建的某些事件添加页面。

I'm aware that I can create a custom template, and then assign a Page to use that template, my question is, once this is done, what are the different ways that I can allow certain content areas to be changed by the client when creating a new page that uses the template. 我知道我可以创建一个自定义模板,然后分配一个页面来使用该模板,我的问题是,一旦完成,我允许客户端在某些内容区域进行更改的方式有哪些?创建一个使用模板的新页面。

For example, If i have a very bare custom template such as the following: 例如,如果我有一个非常简单的自定义模板,例如:

<?php 
/*
Template Name: Retreat Template
*/

get_header(); 

?>

<div class="container-fluid retreat-page-container">
   <h1>The Event Title</h1>
   <p>Some Event Description</p>
   <a href="#">Some Event Link</a>
</div>

<?php get_footer(); ?>

What are the tools I can use so the client is able to change the inner HTML of the <h1> , and <p> tags, or change the href and inner HTML of the <a> tag, when creating a new page that uses the template. 在创建使用以下内容的新页面时,我可以使用哪些工具,以便客户端能够更改<h1><p>标记的内部HTML,或更改<a>标记的href和内部HTML。模板。 Or even things like changing the background image for the container. 甚至还可以更改容器的背景图片。 Obviously, custom CSS could be used to change things like the background image etc, but what if it were wanted to be a different background image for each event that uses the same template? 显然,自定义CSS可以用于更改背景图片等内容,但是如果希望对于使用同一模板的每个事件将其作为不同的背景图片怎么办?

The default page I created, index.php, uses widgetized areas which work great for adding text areas etc. within the wp-admin. 我创建的默认页面index.php使用widgetized区域,非常适合在wp-admin中添加文本区域等。 However, even If I were to add widgetized areas to the custom template, the content that is put in each widgetized area would then be the same across each page that uses the template. 但是,即使我要将小部件化的区域添加到自定义模板中,放置在每个小部件化区域中的内容在使用该模板的每个页面上也将是相同的。

Can anyone please give a Wordpress rookie some advice? 谁能给Wordpress新秀一些建议?

The best two tools that I can think of are: 我能想到的最好的两个工具是:

  1. redux (with the metaboxes add on) https://reduxframework.com/extension/metaboxes/ redux(添加了metabox) https://reduxframework.com/extension/metaboxes/
  2. Advanced Custom Fields https://www.advancedcustomfields.com/ 高级自定义字段https://www.advancedcustomfields.com/

Redux has a cost while Advanced custom fields is free. Redux需要付费,而Advanced自定义字段是免费的。 They both allow you store specific metadata about each individual page that you can then access through your php in the page template. 它们都允许您存储有关每个页面的特定元数据,然后可以通过页面模板中的php访问这些元数据。 I use Redux on my main site I work with everywhere. 我在任何地方都可以使用的主要站点上使用Redux。 https://trulaw.com https://trulaw.com

Redux is a little more advanced in terms of maintenance. Redux在维护方面要先进一些。 Its basically managed via config file in text format. 它基本上是通过配置文件以文本格式进行管理的。 ACF is managed through plugin menus in wordpress. ACF通过wordpress中的插件菜单进行管理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM