Title: &#8216;the_permalink&#8217; not working&#8230;
Last modified: August 19, 2016

---

# ‘the_permalink’ not working…

 *  [skaramouche](https://wordpress.org/support/users/skaramouche/)
 * (@skaramouche)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/the_permalink-not-working/)
 * I’ve been using [this](http://www.mensk.com/tutorials/wordpress/wordpress-as-cms-intro.html)
   as an introduction to WordPress; however, I ran into trouble as I was customizing
   my index.php file. When trying to use php to post a permalink, I’m getting this:
 * [http://skaramouche.awardspace.com/”http://skaramouche.awardspace.com/?page_id=2&#8243](http://skaramouche.awardspace.com/”http://skaramouche.awardspace.com/?page_id=2&#8243);
 * instead of this:
 * [http://skaramouche.awardspace.com/?page_id=2/](http://skaramouche.awardspace.com/?page_id=2/)
 * The same sort of error is happening with the call for the title of the links.
   Here is my index.php:
 *     ```
       <?php get_header(); ?>
       <div id="content" class="narrowcolumn">
       <?php if (have_posts()) : ?>
       <h3>About</h3>
       <?php query_posts('pagename=about'); ?>
       <?php if (have_posts()) : ?>
       <?php while (have_posts()) : the_post(); ?>
       <div class="post"><?php the_excerpt(); ?></div>
       <?php endwhile; ?>
       <?php endif; ?>
       <a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”>
       <span class=”more”>More...</span></a>
       <h3>Services</h3>
       <?php query_posts('pagename=services'); ?>
       <?php if (have_posts()) : ?>
       <?php while (have_posts()) : the_post(); ?>
       <div class="post"><?php the_excerpt(); ?></div>
       <?php endwhile; ?>
       <?php endif; ?>
       <a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”>
       <span class=”more”>More...</span></a>
       <?php else : ?>
       <h2 class="center">Not Found</h2>
       <p class="center">Sorry, but you are looking for something that isn't here.
   
       <?php include (TEMPLATEPATH . "/searchform.php"); ?>
       <?php endif; ?>
       </div>
       <?php get_sidebar(); ?>
       <?php get_footer(); ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  [Andrew Ozz](https://wordpress.org/support/users/azaozz/)
 * (@azaozz)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/the_permalink-not-working/#post-668969)
 * So, how many wp-loops are you running on this page? If you just want to always
   include 1-2 pages, get them with get_posts()
    [http://codex.wordpress.org/Template_Tags/get_posts](http://codex.wordpress.org/Template_Tags/get_posts)
   that creates a mini-loop and has to be outside of the main loop [http://codex.wordpress.org/The_Loop_in_Action](http://codex.wordpress.org/The_Loop_in_Action)
 * the_permalink() only works inside the main loop. For outside the loop you will
   need to know the page/post ID to get a permalink and use get_permalink().
    [http://codex.wordpress.org/Template_Tags/the_permalink](http://codex.wordpress.org/Template_Tags/the_permalink)
   [http://codex.wordpress.org/Template_Tags/get_permalink](http://codex.wordpress.org/Template_Tags/get_permalink)

Viewing 1 replies (of 1 total)

The topic ‘‘the_permalink’ not working…’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Andrew Ozz](https://wordpress.org/support/users/azaozz/)
 * Last activity: [18 years, 4 months ago](https://wordpress.org/support/topic/the_permalink-not-working/#post-668969)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
