WordPress.org

Ready to get started?Download WordPress

Forums

Which function read/analyse pemalinks in WP?? (5 posts)

  1. sailboatvn
    Member
    Posted 6 years ago #

    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

  2. Austin Matzko
    Member
    Posted 6 years ago #

    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.

  3. sailboatvn
    Member
    Posted 6 years ago #

    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

  4. Austin Matzko
    Member
    Posted 6 years ago #

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

  5. sailboatvn
    Member
    Posted 6 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic