WordPress 中的自定义询问页面不起作用
我正在使用 WordPress 创建类似于 stackoverflow.com 的博客,用户可以在其中提问。我决定,由于我的“询问”页面“始终相同”,我创建一个名为ask.php 的新页面。此页面将包含表格。问题是我无法正确链接该页面。
在标题模板中,我给出了我的询问页面的链接。我相信此链接链接到我的主题文件夹中的自定义 php 文件 *wp-content\themes\mythemename*
<a href="<?php echo get_bloginfo('template_directory'); ?>/ask.php"> ask</a>
为了简单起见,我的 Ask (ask.php) 页面的内容只是“diplay one”标题',无循环,无页脚等。
<?php get_header(); ?>
问题是,当我单击询问链接时,会打开一个空白页面。当我将鼠标悬停在链接上时,我可以看到链接是正确的 http://mysitename .com/wp-content/themes/own/index.php,其中“own”是我的主题文件夹。
这是一个问题,我创建了不同的 php 页面并相应地更改了链接,但总是打开一个空页面。即使当我尝试提供指向index.php的链接时
<a href="<?php echo get_bloginfo('template_directory'); ?>/index.php"> Home</a>
I am using wordpress to create blog similar to stackoverflow.com where users can ask questions. I decided that since my Ask page is "same all the time" I create a new page called ask.php. This page will contain the FORM. The problem is that i cannot link that page correctly.
In the header template I give the link to my ask page. I believe this link links to custom php file in my themes folder *wp-content\themes\mythemename*
<a href="<?php echo get_bloginfo('template_directory'); ?>/ask.php"> ask</a>
For the sake of simplicity the contents of my Ask (ask.php) page is just 'diplay one header', no loop no footer etc.
<?php get_header(); ?>
The problem when i click on the ask link an empty page is opened. When i hover mouse over the link I can see the link is correct http://mysitename.com/wp-content/themes/own/index.php, where 'own' is my theme folder.
And this this a problem I created different php pages and changed the link accordingly but always an empty page is opened. Even when I try to give link to index.php
<a href="<?php echo get_bloginfo('template_directory'); ?>/index.php"> Home</a>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,ask.php 主题文件应在顶部包含以下几行:
然后从 wp-admin 添加一个名为 Ask 的新页面,然后从编辑页面的右侧边栏中选择模板
Ask
对于此页面。一切都应该工作得很好。ps 不在您的标题中包含指向该文件的链接,而是让 wp 列出带有您添加页面时在 wp-admin 中设置的永久链接的页面。
First you're ask.php theme file should contain the following lines at the top :
Then add a new page from wp-admin called Ask , and from the right sidebar on the edit page select the template
Ask
for this page . Everithing should work just fine .p.s. don't include a link to the file in you're header but instead let wp list the page with the permalink you've set in wp-admin when you added the page .
听起来好像您在单独的 PHP 文件中创建了一个页面,但未包含 WordPress 标头。如果没有它,您就无法使用
get_bloginfo()
等 WordPress 函数。考虑包含标题,或为您的表单创建静态 WordPress 页面。
另外,请确保将 PHP 错误设置为显示在您的服务器上,以帮助您完成此过程。
It sounds as though you have created a page in a separate PHP file and not included the WordPress header. Without that, you cannot use WordPress functions like
get_bloginfo()
.Consider including the header, or creating a static WordPress Page for your form.
Also, ensure that PHP errors are set to display on your server to help you through this process.