get page templates

Checking for get_page_templates() in the core, I found a workaround that doesn’t break the theme like: Fatal error: Call to undefined function get_page_templates() I’m using this just after <body> and works ok: $templates = wp_get_theme()->get_page_templates(); foreach ( $templates as $template_name => $template_filename ) { echo “$template_name ($template_filename)<br />”; }

How to Rename a Template File?

Chris gave me some good insight, and I appreciate the filter func. But I wound up changing the db through phpMyAdmin: UPDATE wp_postmeta SET meta_value=”new-filename.php” WHERE meta_value=”old-filename.php”;

Customizing get_the_excerpt() to specific length and “Read More” output.

To get a specific length you can use: wp_trim_words function. It has 3 parameters. Text to trim. Ex: get_the_content() Number of words. Ex: 295 What to append after end of the text. Ex: ” This means null. Use this: <span> <?php echo wp_trim_words( get_the_content(), 295, ” ); ?> <i><a style=”color:#1975D1;float:Right;” class=”title” href=”https://wordpress.stackexchange.com/questions/75069/<?php the_permalink() ?>” rel=”bookmark”>Click … Read more

Change the name of the ‘Default Template’

There is a filter for this since version 4.1; cf. https://github.com/WordPress/WordPress/commit/7cdbac53e8497b346d1009375d36586fb6e5197c You can now use: add_filter(‘default_page_template_title’, function() { return __(‘My default template name’, ‘your_text_domain’); });

How to show a under construction page for a domain but still be able to work on index.php?

You can filter template_include and include a special file for users who are not logged in: /* Plugin Name: T5 Under Construction */ add_filter( ‘template_include’, ‘t5_uc_template’ ); function t5_uc_template( $template ) { $uc_template = dirname( __FILE__ ) . ‘/under-construction.php’; if ( ! is_user_logged_in() ) return $uc_template; if ( ! current_user_can( ‘administrator’ ) ) return $uc_template; … Read more

Custom templates folder

As of WordPress 3.4 you can put your page templates in whatever direct subdirectory you need, it doesn’t sound like you can put them into sub-sub directories but I haven’t tested this. I suggest storing templates into /page-templates/ folder as WordPress seems to recognize it. From WordPress Page Templates Entry: WordPress recognizes the subfolder page-templates. … Read more