• 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 “https://www.mysite.com/blog/lorem-ipsum” but everytime I get the permalink inside a post (in my custom template using get_permalink), it returns it as follow: “https://www.mysite.com/?post=lorem-ipsum”.

    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

    (@spiritofthewinds)

    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 “https://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 “https://www.mysite.com/?post=lorem-ipsum&#8221; and the content shows fine. But if I type “https://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

    (@spiritofthewinds)

    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.