The action hook pre_get_posts
is called well before the page template is rendered. Move add_action('pre_get_posts', 'my_pre_get_posts');
and your my_pre_get_posts()
function to your theme’s functions.php
file.
The action hook pre_get_posts
is called well before the page template is rendered. Move add_action('pre_get_posts', 'my_pre_get_posts');
and your my_pre_get_posts()
function to your theme’s functions.php
file.