0
votes

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.

The structure of my theme:

  • index.php
  • header.php
  • sidebar.php
  • footer.php
  • services.php <- other page in the site

Here's the sample code from 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.

3
I am not sure whether you really followed the theme development convention for wordpress or not ..have a look at this- codex.wordpress.org/Theme_Developmentswapnesh
you are not echoing the template url try to echo like this echo bloginfo('template_url')rams0610
I tried echoing it to no avail.neknek mouh

3 Answers

2
votes

There are two ways in wordpress for linking Pages

For Content Based pages only:

You need to create a page from wp-admin(Admin panel) and can specify the slug of the page E.g:

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

This page will always run from page.php.

For HTML Changes Pages:

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.E.g:
Services page will become page-services.php, in this you can insert your own html.

This will run from page-services rather than page.php

Choose as per your requirement.

1
votes

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. I assume the latter is what you're really going for.

-1
votes

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