Paul
Paul

Reputation: 2515

Wordpress add action 'init' not working frontend

I have installed Wordpress without making any changes and using the standard 2019 theme. I want to create virtual pages when ever specific url patterns are called. To do this I need to run a URL rewrite as early as possible, so I have added this line to the top of the themes functions.php file:

function url_rewrite() {
    die('here');
}
add_action('init', 'url_rewrite');

I get the message 'here' as expected on pages, but if its a URL which does not exist the site is not picking this up at all, it just goes to a 404 page. I'm hoping someone knows why.

I have also tried:

add_action('init', 'url_rewrite', 1, 0);

Upvotes: 1

Views: 3041

Answers (1)

Maulik Makwana
Maulik Makwana

Reputation: 71

its working for me perfect, can you please check as you have added code with theme selected and once update your permalink in backend

Upvotes: 3

Related Questions