php 如何在 Wordpress 中创建自定义页面?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9531559/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 07:01:41  来源:igfitidea点击:

How to create a custom page in Wordpress?

phpwordpresscustom-wordpress-pages

提问by Kartik Patel

How can I to create a custom page in Wordpress 3.0. Give me any link of tutorial.

如何在 Wordpress 3.0 中创建自定义页面。给我任何教程链接。

回答by thecodedeveloper.com

WordPress provides a clever way to do this called Custom Page Templates. To create a WordPress Page Template, you'll need to use your text editor. Go to the directory on your server where you installed WordPress, and then navigate to the directory of your theme. Usually that looks something like this: “/wp-content/themes/default” where “default” is your theme name.

WordPress 提供了一种巧妙的方法来做到这一点,称为自定义页面模板。要创建 WordPress 页面模板,您需要使用文本编辑器。转到服务器上安装 WordPress 的目录,然后导航到主题目录。通常看起来像这样:“/wp-content/themes/default”,其中“default”是您的主题名称。

That's where you will create your custom page template file. Create a file called “cover_page.php” and add the following code to it:

您将在那里创建自定义页面模板文件。创建一个名为“cover_page.php”的文件,并在其中添加以下代码:

 <?php
 /*
 Template Name: Cover Page
 */
 ?>

 <?php get_header(); ?>

 Here's my cover page!

<?php get_footer(); ?>  

more details read this

更多细节请阅读本文

http://www.expand2web.com/blog/custom-page-template-wordpress/

http://www.expand2web.com/blog/custom-page-template-wordpress/

回答by IanB

To add to the answers above, one good way is to open a text editor (I like notepad++) and copy and paste the content of the page.php file into a new file, including the php template name code in one of the previous examples.

要补充上面的答案,一个好方法是打开文本编辑器(我喜欢记事本++)并将 page.php 文件的内容复制并粘贴到一个新文件中,包括前面示例之一中的 php 模板名称代码.

Call it something unique (like custom_page1.php ) and upload this file via ftp to your active theme folder inside your wordpress install on your server. You can use filezilla for this or another FTP program.

将其命名为独特的(例如 custom_page1.php )并通过 ftp 将此文件上传到服务器上安装的 wordpress 中的活动主题文件夹。您可以为此或其他 FTP 程序使用 filezilla。

Refresh your editor page in wordpress and you should see your template listed with the others on the right.

在 wordpress 中刷新您的编辑器页面,您应该会看到您的模板与右侧的其他模板一起列出。

Now when you publish a page you can choose this template from the dropdown menu on the side panel.

现在,当您发布页面时,您可以从侧面板的下拉菜单中选择此模板。

回答by Shakti Singh

You can use the Page Templatefeature of wordpress to create a custom page.

您可以使用wordpress的页面模板功能来创建自定义页面。

回答by Vijaya Narayanasamy

  1. First create page using pages->add new.Then,give title (for e.g. aboutus). Then click
    Publish on right side of the window(no content is needed for the custom page).
  2. Then,on left side of window click Appearance->Menus.
  3. In menus window,on left side you will see Pages heading,in that click Most Recent and
    check aboutus page. Then it will be shown on right side window.
  4. Then,on left above Pages heading, you will see Custom Links, in that enter # in URL textbox and aboutus in Label textbox. Then click Add to Menu button.
  5. Done. You will see the menu as custom on right side of the window and then click save menu button at the bottom right.
  6. Then to check, on left top of the window click the website or your blog name. You will see the menu. Click on it. No changes will occur.
  1. 首先使用 pages->add new 创建页面。然后,给出标题(例如 aboutus)。然后单击
    窗口右侧的发布(自定义页面不需要任何内容​​)。
  2. 然后,在窗口左侧单击外观->菜单。
  3. 在菜单窗口中,您会在左侧看到页面标题,在该页面中单击最近并
    查看关于我们的页面。然后它将显示在右侧窗口中。
  4. 然后,在页面标题的左侧,您将看到自定义链接,在 URL 文本框中输入 #,在标签文本框中输入 aboutus。然后单击添加到菜单按钮。
  5. 完毕。您将在窗口右侧看到自定义菜单,然后单击右下角的保存菜单按钮。
  6. 然后进行检查,在窗口的左上角单击网站或您的博客名称。你会看到菜单。点击它。不会发生任何变化。

That's it, done!

就这样,大功告成!

回答by Phillip Madsen

Here are some plugins you can use while creating what you need then you can turn them off or remove them.

以下是一些您可以在创建所需内容时使用的插件,然后您可以将它们关闭或删除。

http://wordpress.org/extend/plugins/theme-file-duplicator/
http://wordpress.org/extend/plugins/theme-file-maker/

http://wordpress.org/extend/plugins/theme-file-duplicator/
http://wordpress.org/extend/plugins/theme-file-maker/

Very easy way to do what you need.

非常简单的方法来做你需要的。

回答by john0514

This is a very simple part of WordPress theme development, I suggest giving the documentation (the WordPress Codex) a good read before going any further. There are also a tonne of great WordPress tutorial sites out there that will get you heading in the right direction.

这是 WordPress 主题开发的一个非常简单的部分,我建议在继续之前仔细阅读文档(WordPress Codex)。还有大量很棒的 WordPress 教程网站可以让您朝着正确的方向前进。