简体   繁体   English

如何将页面链接链接到wordpress

[英]how to link a page url to wordpress

I'm new to WordPress, I just converted my HTML to WP Theme, but now I'm facing a problem, I couldn't get to work the linking of pages. 我是WordPress的新手,我刚刚将我的HTML转换为WP主题,但现在我遇到了一个问题,我无法处理页面的链接。

The structure of my theme: 我的主题结构:

  • index.php 的index.php
  • header.php header.php文件
  • sidebar.php 的sidebar.php
  • footer.php footer.php
  • services.php <- other page in the site services.php < - 网站中的其他页面

Here's the sample code from index.php: 这是index.php的示例代码:

<div id="menu">
   <ul>
      <li><a class="current" href="#">Home</a></li>
      <li><a href="<?php bloginfo("template_url")?>/services.php">Services</a></li>
      <li><a href="<?php bloginfo("template_url")?>/services.php#freequote">Free Quote</a></li>
      <li><a href="<?php bloginfo("template_url")?>/customers.php">Customers</a></li>
      <li><a href="<?php bloginfo("template_url")?>/about.php">About Us</a></li>
      <li><a href="<?php bloginfo("template_url")?>/contact.php">Contact us</a></li>
   </ul>
</div>

But whenever I try to go to services, it's giving internal server error. 但每当我尝试去服务时,它都会给出内部服务器错误。 I don't know why it's happening. 我不知道为什么会这样。

There are two ways in wordpress for linking Pages 在wordpress中有两种方法可以链接Pages

For Content Based pages only: 仅适用于Content Based页面:

You need to create a page from wp-admin (Admin panel) and can specify the slug of the page Eg: 您需要从wp-admin (管理员面板)创建一个页面,并可以指定页面的slug例如:

<li><a href="<?php bloginfo("template_url")?>/services">Services</a></li>
                                              ^This is called Slug

This page will always run from page.php . 此页面将始终从page.php运行。

For HTML Changes Pages: 对于HTML Changes页面:

You need to create a page from wp-admin (Admin panel) and create a file containing page-slug.php , here slug will change according to the name of page.Eg: 你需要从wp-admin (管理面板)创建一个page-slug.php并创建一个包含page-slug.php的文件,这里slug将根据page的名称改变.Eg:
Services page will become page-services.php , in this you can insert your own html . Services页面将成为page-services.php ,在此您可以插入自己的html

This will run from page-services rather than page.php 这将从page-services而不是page.php

Choose as per your requirement. 根据您的要求选择。

Try using: 尝试使用:

<a href="<?php echo bloginfo("template_url")?>/services.php">

I think in this case you are just not echoing out the value of that function. 我想在这种情况下你只是没有回应出那个函数的价值。 Also, however you might want this instead: 此外,您可能需要这样做:

<a href="<?php echo home_url() ?>/services">

The template_url goes to your theme's folder, not to your website's homepage. template_url会转到您主题的文件夹,而不是您网站的主页。 I assume the latter is what you're really going for. 我认为后者是你真正想要的。

try <php echo site_url()."/sevices.php"; ?> 尝试<php echo site_url()."/sevices.php"; ?> <php echo site_url()."/sevices.php"; ?>

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

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