I installed latest XAMPP & extracted latest WordPress to this path: C:\xampp\htdocs
I activated default theme: Active: Twenty Twenty
I created these:
1 Page called test: http://localhost:82/test/
1 Post called test: http://localhost:82/2022/04/11/test/
- I accessed & edited the theme file called singular.php & wrote the following to see what the filename gets printed as:
<?php echo $_SERVER["PHP_SELF"], PHP_EOL; ?>
I refreshed above 2 URLs & this php function prints /index.php & not /singular.php. WTH!
But when I insert the above code (or just ANYTHING) inside "index.php, & reload the above 2 URLs (page & post), then nothing I wrote in index.php shows up.
My direct 2 Questions are:
What's going on? Why is singular.php the file being accessed while PHP prints that the current filename is /index.php?
How does WordPress know that it should load singular.php (& not any other php file)? I looked at page & I even don't read this line at all:
<?php /* Template Name: Example Template */ ?>
Doesn't WordPress count on PHP filename to know which file is for Page & which for Posts?
- Here's the theme structure:
- Here's C:\xampp\htdocs.htaccess content:
<IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>