I ran into problem but I couldn't resolve the issue. I read so many post and reset WordPress and using Xampp. I don't know why everything is messed up. Build system even not showing php in sublime text 4.
When I ran my local host it gives:
My theme folder is here. I know there are questions have been asked but they are somehow different.
<h1><?php bloginfo('name') ?></h1>
This is because you're accessing your theme files from the browser. I can see from your URL that you're accessing your theme index.php
file directly. This is bypassing WordPress and the functions it makes available to you.
Ensure your custom theme is active within the WordPress admin area, and then visit your WordPress website url: http://localhost/warda/wordpress/
. This will load WordPress and then WordPress will load your theme. You should no longer have the error.
For example, suppose you have an index.php
file that contains:
<?php
function custom_function() {
echo 'Hello, World!';
}
require __DIR__ . '/extra.php';
And an extra.php
file that contains:
<?php
custom_function();
If you open index.php
in the browser it will register a function called custom_function
, then load extra.php
and then execute the function. It will output Hello, World
.
If you open extra.php
in the browser, it will attempt to execute custom_function
, but because it has not been defined yet, it will throw an "undefined function" error.
This is essentially what is happening with your WordPress theme.