sailboatvn
Member
Posted 1 year 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
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.
sailboatvn
Member
Posted 1 year 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
WordPress is licensed under the GPL 2, so any code you take needs comply with it.
sailboatvn
Member
Posted 1 year ago #
Yes, i'll do that. Many thanks for your replies filosofo.