Example:
add_action('wp', function () {
if (is_singular()) echo 'This page is singular';
});But you can do the same thing in "pre_get_posts" hook (earlier than "wp") like this:
add_action('pre_get_posts', function ($Q) {
if (!$Q->is_main_query()) return;
if ($Q->is_singular) echo 'This page is singular';
});https://codex.wordpress.org/Conditional_Tags
$fn = function ($Theme) {
echo "Current theme is $Theme";
return 'my-theme'; // Switch theme to 'my-theme'
};
add_filter('stylesheet', $fn, 11);
add_filter('template', $fn, 11);