Dynamic URL Routing
-
Based on the path, I’m able to write custom routes to get the correct page, and set some custom variables… for example:
If the route takes a URL in this format:
http://example.com/products/:product_nameAnd we hit this URL:
http://example.com/products/baseball-gloveAnd we’re able to retrieve the page by doing:
get_page_by_path('products/product');Right now, the original query initially searches for
products/baseball-glovewhich returns theWP_Postobject for404 / Page Not Found, even though my subsequent query withget_page_by_pathgets me the correctWP_Postobject. How can I reset the global$postobject to overwrite the currentWP_Postand so that other plugins are able to use functions like thethe_title()?
The topic ‘Dynamic URL Routing’ is closed to new replies.