-2

How to change Ugly link from

www.test.com/?p=123

to

test.com/123

I want to make two types of links:

www.test.com/123-my-post-title-name

www.test.com/123

The latter should lead to the first.

  • What is 123? What is 123-simpenews? – Rarst Apr 10 '16 at 11:26
  • its 1 news. But /123 will redirect to /123-simplenews You come to test.com/123 and you are redirected to test.com/123-simplenews – Mkdir Apr 10 '16 at 11:53
  • question is still not clear. What do you mean in wanting to have two types of links, when will the one be used and when the other and what process will generate them? – Mark Kaplun Apr 10 '16 at 16:49
  • Now www.test.com/123-my-post-title-name www.test.com/?p=123 I want www.test.com/123-my-post-title-name www.test.com/123 – Mkdir Apr 10 '16 at 17:33
1

Settings --> Permalinks. Choose 'post name'.

See the official Wordpress codex page for more.

  • But I need to be redirected from test.com/123 ("123" - post ID) to test.com/123-simplenews ("123"- post ID, "simplenews"- post name) – Mkdir Apr 10 '16 at 12:45
0

This Ugly Links you call in WordPress is named Permalinks. There are many formats of Permalinks, such as:

  • Default
  • Day and Name
  • Month and Name
  • Numeric
  • Post Name (used by most of WordPress Themes on web now-a-days)
  • Custom Structure

I didn't quite understand your question, Did you change the Permalink some how? Are you getting redirected? Or, Would like to get redirected? Because if you would, I'm afraid it's not possible for you to do URL's redirecting this way (Unless if you want to mess around with your code, then go ahead).

Something nice about Permalinks in WordPress is that it offers to us an awesome flexibility to create our own custom URI. It gives to us some sort of tags to mess around that looks something like this:

  • %year%
  • %monthnum%
  • %day%
  • %hour%
  • %post_id%
  • etc...

Go to https://codex.wordpress.org/Using_Permalinks to know more about the Custom URI Tags and see how WordPress URI Formats is structured.

If you're planning to add some extra information to your URI that the WordPress does not offer (let's say a - symbol), you need to know that, we don't place this kind of stuff explicitly on the URL, if you do so, it'll break your Theme or Plugin, and it might give you a hard time to figure it out.

For security measures URL's are encoded by the Browser, blocking any kind of suspicious/malicious attempt to hack your Theme or Plugin. Please take a look to HTML URL Encoding by W3C, it will give you a set of UTF-8 encoding standards.

Real World Example

Let's say that you want to create the following structure:

www.test.com/123-my-post-title-name

I suppose it could be easily done by selecting the Custom Structure from WordPress Formats and place at the URI input this %post_id%%2D%%postname% instruction.

  • Yeah. I know how to make Permalinks. I made this: www.test.com/123-my-post-title-name And I also want to make redirection from www.test.com/123 to www.test.com/123-my-post-title-name Now in Wordpress redirection works like this www.test.com/?p=123 – Mkdir Apr 10 '16 at 15:41
  • Why would you do this? Because when the user open your Single Post Page the URL will be already www.teste.com/123-my-post-title-name, and there's no need for redirection. – iszwnc Apr 10 '16 at 15:48
  • Yes, but I want the link to be short when I give it to somebody. www.test.com/123 which redirects to www.teste.com/123-123-my-post-title-name looks better. – Mkdir Apr 10 '16 at 16:03
  • In my opinion there is no need to create a Custom Short URL for (as I suppose) a small theme, there are plenty of URL Shortener Services out there on web, such as Google URL Shortener, Bitly and many others. There is an option if you really want to create a Custom Short URL, please would you click here to see more of how you can do it? Thanks :D – iszwnc Apr 10 '16 at 16:14
  • Its bad variant – Mkdir Apr 10 '16 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.