Walrus
Walrus

Reputation: 20464

Wordpress First Index PHP location

What is the first php file wordpress goes to to determine what page, document or URL to load. I have some PHP I want executed to determine what happens when certain URL's are entered. At the moment it's in the 404.php for want of a better place.

This however is not ideal. The index.php in theme is not referenced so what is?

Upvotes: 0

Views: 234

Answers (1)

Mr. BeatMasta
Mr. BeatMasta

Reputation: 1312

It's one of the many pages loaded from wp-settings.php. Anyway, you don't have to go that deep into the core structure and spoil WP's native functionality I think, you can do whatever you prefer in theme functions.php, so you can get a page name just by doing something like this in functions.php:

$pagename = get_query_var('pagename');
if ( !$pagename && $id > 0 ) {
    $post = $wp_query->get_queried_object();
    $pagename = $post->post_name;
}

Upvotes: 1

Related Questions