Redirect page to homepage, keeping URL
Redirect page to homepage, keeping URL
Redirect page to homepage, keeping URL
In my development experience. get_template_part() is better way to maintain In the future. https://developer.wordpress.org/reference/functions/get_template_part/
How to include a page template and template part into my plugin
Solved! just need to change get_theme_file_path() to get_template_directory()
Use TEMPLATEPATH for custom url
I don’t quite understand what you mean but this might work get_template_part()
Is there a way for me to use the theme page.php (or single.php) template, intercepting the query to replace it with a wp_user_query or does this have to be a custom template job? No, WP pages are either post archives or singular posts, based on a WP_Query. You can create virtual pages based on rewrite … Read more
Should all CPT “lecture” posts use this template? If so, just rename your file single-lecture.php and place it in the root directory of your theme, and WP will automatically use it due to its template hierarchy. If instead you’re trying to assign this custom template to hand-picked pages, wherever you register your post type, add … Read more
It turns out that $wp->query_vars[“post_type”] contains the data I need, regardless of whether the request method is GET or POST. namespace mynamespace; class MyPlugin { public static function template_include($template) { global $wp; if ($wp->query_vars[“post_type”] == ‘thing’) { return plugin_dir_path( __FILE__ ) . ‘templates/thing.php’; } return $template; } } add_filter(‘template_include’, ‘\mynamespace\MyPlugin::template_include’); Also, it appears that the … Read more
EDIT Undeleted my answer as the code seems to have helped the OP. Originally got beaten by @TomJNowell, so some content might be the same ORIGINAL ANSWER This is more PHP related than WordPress. Anonymous functions, the syntax used in the code given, was only introduced in PHP 5.3 and will not work in older … Read more