简体   繁体   English

如何在WordPress页面中部分添加HTML页面

[英]how to add html page in wordpress page partially

I am new to wordpress. 我是Wordpress的新手。 I want to partially render some html code to wordpress page from admin section. 我想部分呈现一些html代码到admin部分的wordpress页面。

Description : i have a file menu.php with contains some html elements. 描述:我有一个文件menu.php,其中包含一些html元素。 Is it possible to inject this file to a page from admin section while editing page information. 编辑页面信息时是否可以从管理部分将此文件注入页面。

Many Thanks. 非常感谢。

M 中号

[1] You can simply add html code/elements in the page/post. [1]您只需在页面/帖子中添加html代码/元素。 Have a look to this screenshot: https://www.diigo.com/item/p/rapdderzccaddbecazbecorocb 看看这个屏幕截图: https : //www.diigo.com/item/p/rapdderzccaddbecazbecorocb

OR [2] You can create a template as described below : Duplicate post.php or page.php in your theme folder (under /wp-content/themes/themename/). 或[2]您可以按如下所述创建模板:在主题文件夹(在/ wp-content / themes / themename /下)中复制post.php或page.php。

Rename the new file as templatename.php (where templatename is what you want to call your new template!). 将新文件重命名为templatename.php(其中templatename是您要称为新模板的名称!)。 Enter the following at the top of the new file: 在新文件的顶部输入以下内容:

<?php
/*
Template Name: templatename
*/
?>

You can modify this file (using php) to include other files or whatever you need. 您可以修改该文件(使用php)以包括其他文件或任何您需要的文件。

Then create a new page in your WordPress blog, and in the page editing screen you'll see a 'Template' dropdown in the 'Attributes' widget to the right. 然后在WordPress博客中创建一个新页面,在页面编辑屏幕中,您会在右侧的“属性”小部件中看到一个“模板”下拉列表。 Select your new template and publish the page. 选择您的新模板并发布页面。

Your new page will use the php code defined in templatename.php 您的新页面将使用templatename.php中定义的php代码。

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

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