Note that there are some explanatory texts on larger screens.

plurals
  1. POWordpress: How do I convert a generated URL (permalink) to a pretty URL?
    text
    copied!<p>In a plugin, I am generating a paginated link to a category,<br /> i.e. <code><a href="http://localhost/?cat=17&amp;paged=5" rel="nofollow noreferrer">http://localhost/?cat=17&amp;paged=5</a></code>. The category is known by slug and id.</p> <p>Is there a way to have this URL converted to the user defined "nice permalink" format,<br/> i.e. <code><a href="http://localhost/category/foo/page/5" rel="nofollow noreferrer">http://localhost/category/foo/page/5</a></code>?</p> <p>(Assuming we're running Wordpress 2.8/2.9+)</p> <p><strong>Edit:</strong> Since there are some misunderstandings about what I'm trying to achieve, here's what I have:</p> <ul> <li>The category ID</li> <li>The page number (i.e. the fifth page of that category's archive)</li> </ul> <p>With these data I can create the URL to that page, which would be, for example, <code>http://localhost/?cat=17&amp;paged=5</code>, and that works well. The problem is of a visual nature: If the user has pretty permalinks enabled, then this won't fit in very well. Question is: How do I get the correct, pretty permalink (i.e. <code><a href="http://localhost/category/foo/page/5" rel="nofollow noreferrer">http://localhost/category/foo/page/5</a></code>) from (or for) the information I have?</p> <p><strong>Edit 2:</strong> Obviously if a user has pretty permalinks <em>disabled</em>, then there are no pretty permalinks. I know that, and that is really not subject of the question ... For the moment, let's just assume the user has an <em>arbitrary</em> permalink setting. I generate a link, and it should look like the user wants it to.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload