php - WordPress 'post_name' in posts table duplicated


I'm trying to receive all portfolio entries from the database. I want to list this and also link the WordPress path to it. This is the SQL query:

SELECT id, post_title, post_name FROM 1bncopo2_posts WHERE post_type='portfolio';

post_title could be the following:

  1. Mercedes-Benz AMG C63
  2. Mercedes-Benz S500
  3. BMW 650i XDrive

and now post_name for the first entry of the above list ismercedes-benz-amg-c63. However, I found that in my database table, multiple portfolio vehicles (even vehicles by BMW, etc.) havepost_name set tomercedes-benz-amg-c63. My idea was to generate the URL to the portfolio item usingpost_name as an appendix to the wordpress path. TO BE CLEAR: This is going to be a seperate application reading from the WordPress installation's database and trying to make up the corresponding links to the portfolio items.

Now thatpost_name is notUNIQUE or something I could use, I have two questions:

  1. Why would the WP database allow for duplicatedpost_names?
  2. How can I get the post (portfolio)'s URL, if not bypost_name?



It is impossible to repeat the link, if you see the link from the beginning you will find it different.

If this post(mercedes-benz-amg-c63) for custom post type called(portfolio) you see URL like:

But if its post type (post) you see URL like:

Then as you see the URL not duplicated

People are also looking for solutions to the problem: php - Does flock lock the file across processes?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.