views:

141

answers:

2

i still , don't understand , how wordpress can understand what is this url refer to : www.mysite.com/about-me/

they are using no identifier

if they using slug functions so how they can retain story information or in other word , how they change back the slugged title to select from database

A: 

This is just a guess:

My guess is that they store the titles in a database, and make sure every title is unique. That way, they can do a look-up by title and know which item is coupled to that.

Ikke
+6  A: 

It processes the "pretty" URL and queries the database with that data. Of course slugs are checked to be unique on creation. Details are in the function url_to_postid() in the file wp-includes/rewrite.php.

If you want to directly obtain the id from the slug you can query the database:

SELECT ID
FROM wp_posts
WHERE post_name = '$slug'

you might need to check wp_posts which is the default name, but it depends on the installation.

kemp
ok now how can i write that function for my project and change post title to post id
Mac Taylor
See updated answer
kemp
and u r saying that wordpress store slug in its table !?but i didnt see any slug in the table
Mac Taylor