Support » Plugins and Hacks » Which function read/analyse pemalinks in WP??

  • Hi Guys,

    I’m quite stumbled trying to figure out which functions / classes in WordPress pickup and analyse the URLs

    There are 2 URLs type in WordPress for example

    Link 1. http://www.domainname.com/?p=5
    Link 2. http://www.domainname.com/clothing/jeans/black/long

    I figured out the file wp-included/cananical.php to analyse the link 1 and convert to Link2, then redirect and display Link 2. Its quite clear and easy to analyse the link1 based on parameter “p=5”, but how WordPress can understand the Link2??????????

    Is there anyone know which class/method read/ananlyse the Link2 and let me know please.

    Many thanks,
    Dave

Viewing 4 replies - 1 through 4 (of 4 total)
  • Well, it depends on where and when it’s happening. For most links like your #2, WordPress attempts to parse the query in the WP class in the parse_request method (you can see this in wp-includes/classes.php).

    But WordPress also has a function named url_to_postid; if you pass a url to it from the blog, it will attempt to return the corresponding post’s id.

    Hi filosofo,

    Thank you very much for your answer, I really appreciate it. I also figured it out yesterday about the wp-includes/classes.php class but did not know about the function named url_to_postid ( its worth looking into it as well though)

    Whatif I use WordPress code for my own application (e-commerce)?? I know wordpress is open-source application, however, should I need to ask WordPress people first?

    Regards,
    Dave

    WordPress is licensed under the GPL 2, so any code you take needs comply with it.

    Yes, i’ll do that. Many thanks for your replies filosofo.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Which function read/analyse pemalinks in WP??’ is closed to new replies.