How does routing on wordpress work?

In WordPress, URLs don’t map to routes. They map to database queries. When using WordPress in the “default” permalinks mode, you have a set of variables in the main URL query, like ?p=1 or ?page=234 and so forth. There’s also ?s=search and many others. If you use the “pretty” permalinks, then a big set of … Read more

Use a template file for a specific url without creating a page

You can just look at url, load the file and exit. That can be done when WordPress loaded its environment, e.g. on ‘init’. add_action(‘init’, function() { $url_path = trim(parse_url(add_query_arg(array()), PHP_URL_PATH), “https://wordpress.stackexchange.com/”); if ( $url_path === ‘retail’ ) { // load the file if exists $load = locate_template(‘template-retail.php’, true); if ($load) { exit(); // just exit … Read more

How does WordPress generate URL slugs?

As per @SinisterBeard‘s very valid comment to the question already a couple of years back now, this answer has long been outdated and the mentioned function(s) hence been replaced by a newer API: See wp_unique_post_slug. Original Answer Off the bat, I can’t give you a page/tutorial/documentation on how WP slugs are generated, but take a … Read more

Detecting a WordPress URL without doing a full HTTP GET?

From my experience and quick code search there are no deliberate ways WP identifies itself in headers. However there are some that seem distinct enough and not likely to be customized. HEAD to /wp-login.php will contain following for .org install: Set-Cookie: wordpress_test_cookie=WP+Cookie+check; path=/ And for .com: Set-Cookie: wordpress_test_cookie=WP+Cookie+check; path=/; domain=.wordpress.com Cookie name is customizable by … Read more

remove “index.php” from permalinks

Go to your WP-ADMIN–>Settings–>Permalink and use the permalink structure change there, if it generate any .htaccess file copy the content and update your .htaccess file. Or Check if your hosting mod_rewrite is enable by creating a file phpinfo.php with content, <?php phpinfo();?> Upload this file and browse via Browser. So you know which modules are … Read more

How do I get the avatar URL instead of an HTML IMG tag when using get_avatar?

Good news for WordPress versions 4.2+ Since version 4.2 the handy get_avatar_url() function, introduced as a feature request in ticket #21195 few years ago, now ships with the core: /** * Retrieve the avatar URL. * * @since 4.2.0 * * @param mixed $id_or_email The Gravatar to retrieve a URL for. Accepts a user_id, gravatar … Read more