Title: Get_permalink returning wrong URL
Last modified: August 20, 2016

---

# Get_permalink returning wrong URL

 *  [SpiritOfTheWinds](https://wordpress.org/support/users/spiritofthewinds/)
 * (@spiritofthewinds)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/get_permalink-returning-wrong-url/)
 * I am using the pretty permalinks with WordPress. I have put “/blog/&postname%”
   under “Custom structure” in the Permalinks submenu.
 * I can indeed access the page using “[http://www.mysite.com/blog/lorem-ipsum&#8221](http://www.mysite.com/blog/lorem-ipsum&#8221);
   but everytime I get the permalink inside a post (in my custom template using 
   get_permalink), it returns it as follow: “[http://www.mysite.com/?post=lorem-ipsum&#8221](http://www.mysite.com/?post=lorem-ipsum&#8221);.
 * Is there a way to get the pretty URL and not the default “?post=” URL? Both are
   working but I only want the pretty URL to show in my links.
 * I can’t find anything about this…
 * Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [SpiritOfTheWinds](https://wordpress.org/support/users/spiritofthewinds/)
 * (@spiritofthewinds)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/get_permalink-returning-wrong-url/#post-2300295)
 * Okay, I’m adding some details because I really need to fix this.
 * I am running my WordPress installation with IIS installed on the server. I think
   the cause of my pretty URLs not working for my posts is because I am running 
   it on IIS and thus .htaccess is not used.
 * My Permalinks settings is like this:
    `/blog/%postname%`
 * I currently have this in my web.config:
 *     ```
       <?xml version="1.0" encoding="UTF-8"?>
       <configuration>
         <system.webServer>
           <rewrite>
             <rules>
               <rule name="wordpress" patternSyntax="Wildcard">
                 <match url="*" />
                 <conditions>
                   <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                   <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                 </conditions>
                 <action type="Rewrite" url="index.php" />
               </rule>
             </rules>
           </rewrite>
         </system.webServer>
       </configuration>
       ```
   
 * I created a Page called “Blog” which is at “[http://www.mysite.com/blog/&#8221](http://www.mysite.com/blog/&#8221);
   and in that template I use the loop to grab all the posts. However, user get_permalink
   or the_permalink returns URLs as “[http://www.mysite.com/?post=lorem-ipsum&#8221](http://www.mysite.com/?post=lorem-ipsum&#8221);
   and the content shows fine. But if I type “[http://www.mysite.com/blog/lorem-ipsum&#8221](http://www.mysite.com/blog/lorem-ipsum&#8221);,
   the content **still shows** perfectly, but this URL is not returned by the permalinks
   functions. Is there a way to precise that I want the pretty URL to be returned
   in my blog list?
 *  Thread Starter [SpiritOfTheWinds](https://wordpress.org/support/users/spiritofthewinds/)
 * (@spiritofthewinds)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/get_permalink-returning-wrong-url/#post-2300307)
 * Oh well, I worked a temporary workaround because I couldn’t find how to fix it.
 * I used a custom function call in my template which does the following:
 *     ```
       function get_blog_permalink()
       {
       return qtrans_convertURL(str_replace("?post=", "blog/", get_permalink()));
       }
       ```
   
 * So far, all links are valid and show correctly, I guess my fix is good enought…

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Get_permalink returning wrong URL’ is closed to new replies.

## Tags

 * [friendly](https://wordpress.org/support/topic-tag/friendly/)
 * [get](https://wordpress.org/support/topic-tag/get/)
 * [permalink](https://wordpress.org/support/topic-tag/permalink/)
 * [pretty](https://wordpress.org/support/topic-tag/pretty/)
 * [wrong URL](https://wordpress.org/support/topic-tag/wrong-url/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 1 participant
 * Last reply from: [SpiritOfTheWinds](https://wordpress.org/support/users/spiritofthewinds/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/get_permalink-returning-wrong-url/#post-2300307)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
