在 wordpress 上创建自定义页面并向其添加内容 [英] Creating a custom page on wordpress and adding content to it

查看:42
本文介绍了在 wordpress 上创建自定义页面并向其添加内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在网站(CMS Wordpress)上创建一个php页面,但我不明白如何合并模板文件,例如

<?php get_header();?>

以及其他内容.我知道可以通过管理界面创建页面,但我不适合...如果您尝试创建一个模板文件页面,然后直接链接:

http://local/wp-content/themes/mytheme/mypage.php

预嵌入代码

<?php get_header();?>

它会像这样失败:

致命错误:调用未定义的函数 get_header()

我该怎么办?我怎么能说"这个 CMS 页面对我很重要,并且它执行一些功能?也就是说,事实上,获取到她的完整 url 并且没有给出错误......

解决方案

您需要在脚本中包含 wp-load.php 才能使用任何 WP 功能:

<代码>

试试看.xD

I want to create a php page on the website (CMS Wordpress), but I do not understand how to incorporate the template files, for example

<?php get_header(); ?>

And other content. I know that it is possible to create pages through the admin interface, but I do not fit... if you try to create a page of template files and then go for it the direct link:

http://local/wp-content/themes/mytheme/mypage.php

with pre-embedding the code

<?php get_header(); ?>

it will fail like:

Fatal error: Call to undefined function get_header()

What should I do? How i can "say" this CMS that the page is important for me, and it performs some functionality? That is, in fact, get the full url to her and that did not give out errors…

解决方案

You need to include wp-load.php in your script to use any of WP functions:

<?
require_once('../../../wp-load.php');
get_header(); ?>

try that. xD

这篇关于在 wordpress 上创建自定义页面并向其添加内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆