最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - What is the right way to show reusable content

programmeradmin1浏览0评论

I am very new to Wordpress. I need to update a site that has staff images added manually to every page on 50+ pages. It is time consuming for the business owner (site admin) to change one staff member. They want a component that allows one change and this change would appear on every page. Please tell me is this is the correct approach:

  • create a plugin that allows the admin to edit staff info

  • this plugin on the back end allows them to add images, add info and display current info

  • when the change is made, this plugin writes html/php to show-staff.php file

  • to display the content on every page on the front end i would then add a hook to functions.php:

    add_action('get_footer', 'render_reusable');   
    function render_reusable() {       
        include 'file/path/to/show-staff.php'; 
    } 

Is this the correct approach? What is a better way to render a custom component on the front end?

I am very new to Wordpress. I need to update a site that has staff images added manually to every page on 50+ pages. It is time consuming for the business owner (site admin) to change one staff member. They want a component that allows one change and this change would appear on every page. Please tell me is this is the correct approach:

  • create a plugin that allows the admin to edit staff info

  • this plugin on the back end allows them to add images, add info and display current info

  • when the change is made, this plugin writes html/php to show-staff.php file

  • to display the content on every page on the front end i would then add a hook to functions.php:

    add_action('get_footer', 'render_reusable');   
    function render_reusable() {       
        include 'file/path/to/show-staff.php'; 
    } 

Is this the correct approach? What is a better way to render a custom component on the front end?

Share Improve this question edited Feb 11, 2020 at 20:32 Tom J Nowell 61.2k7 gold badges79 silver badges148 bronze badges asked Feb 11, 2020 at 14:56 VilleLipponenVilleLipponen 1033 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

I can think of two much simpler, more "WordPress way" approaches.

First approach: create a custom theme or a child theme, and make a custom footer with room for widgets. This way, the business owner will be able to go in and edit a single widget with whatever photos and other updates are needed, and they will apply sitewide.

Second approach: create a Reusable Block.

In the Block Editor, you can create the full grouping of staff photos (and whatever other info is needed) inside of a single Group block. Once it's created, you can save it as a Reusable Block, and add it to every Page/Post/wherever it needs to be added. Whenever you need to make updates, you can simply open up the one Reusable Block, make the updates, and save them - and voila, it will be updated every single place that reusable block has been added.

Both require no coding skills or special technical knowledge, and both can be completed by anyone with Editor rights (a.k.a. the business owner).

发布评论

评论列表(0)

  1. 暂无评论