Register Page Template from Plugin

You misunderstand what page_template does. It does not create a new template that you will “show up” somewhere and that you can use. It replaces the page.php template provided by the theme. I think that what you want is template_redirect: function custom_page_template( $page_template ) { if (is_home()) { get_header(); echo ‘do stuff’; get_footer(); } } … Read more

Find the page template of the previous page

You can use wp_get_referer(); to get a URL of previous page from where user came. Then get the last slug part of the URL. Then compare if the slug matches with slug of your custom search-result page template. Then you can decide whether to show or not to show ‘Back to search results’ link. Please … Read more

Categorizing Page Templates

Great question. As far as I can tell there isn’t a way to filter this list (there’s a long trac ticket about a proposal to, if you’re interested, and also related (but different) questions on this site here and here). Because there’s no filter, you may have to resort to doing it with jQuery. We … Read more

Custom metabox for custom page template

<? // Check: // 1. If you are editing post, CPT, or page // 2. If post type IS NOT SET if( ‘post.php’ == basename($_SERVER[‘REQUEST_URI’], ‘?’ . $_SERVER[‘QUERY_STRING’]) && !isset($_GET[‘post_type’]) ) { // get post ID $postid = $_GET[‘post’]; // check the template file name if (‘my_template.php’ == get_page_template_slug($postid) ) { // add your metabox … Read more

Can Page Templates be Applied to Archive and Post Templates?

If you would like all Post Types to have template selection functionality, please update to WordPress version 4.7. Quoted from the codex page linked above: Page Templates for Post Types Add support for post type templates. Add support for post type templates. By opening up the page template functionality to all post types, theme developers … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)