Variable use in get_template_part
D’oh, it just needs a global as its inside a function. messages.php: <?php global $message; echo $message; ?>
D’oh, it just needs a global as its inside a function. messages.php: <?php global $message; echo $message; ?>
Digging through the source code I couldn’t really find any weird logic that would cause ‘category__in’ to break the ordering of the results. If you do, you might as well file a bug in the WordPress Trac. It’s also hard to reproduce this sort of issue, because it might depend on another issue which is … Read more
TL;TR? Spoiler alert – hover over the next blockquote to expose it. Building an archive that is easily filterable by the currently entered password is nothing that is easy and surely not elegant buildable. The solution involves a secondary query and a small plugin, but it works. All errors and wrong paths are shown as … Read more
There is no specifica template for child pages, but you can do this pretty easily with the get_template_part() function. First create a file called “content-child.php”. Second create a file called “content.php”. Next, inside of page.php, place this: if( $post->post_parent !== 0 ) { get_template_part(‘content’, ‘child’); } else { get_template_part(‘content’); } Anything that you want displayed … Read more
OK, so it all comes to finding proper filter to modify the list of available templates… The list of templates comes from get_page_templates function, but there are no filters in it’s code. But… It uses method get_page_templates of class WP_Theme and this one will come handy, because there is a filter applied in there: return … Read more
What I would advice, and have done myself when making WordPress sites for clients. Create a custom post type that they can’t get access to. You can achieve this by conditionally removing the post type from the admin sidebar. One of the ways to solve that problem is to add a custom capability to the … Read more
This is an interesting question, though a bit too broad for a Q&A model. Here is what I would do: Create a custom post type, where each post is a block of content Create a second custom post type for pages that are assembled from blocks of code. In stead of a content field, create … Read more
On the admin side, you could update the meta data for the page-post_type programmatically: global $post; if ( ‘swiss_cheese’ === $post->post_parent AND is_admin() ) update_post_meta( $post->ID, ‘_wp_page_template’, ‘some_template.php’ ); On the visitor facing side, you can simply jump into template redirect: function wpse63267_template_include( $template ) { global $post; if ( ‘swiss_cheese’ === $post->post_parent ) { … Read more
You could dynamically register sidebars. When you register sidebars, you could query for all of your animal pages, loop over all pages, and register a unique sidebar for each page. Adding a page would automatically create a sidebar for it. However – that’s a lot of sidebars. For something tightly coupled with the page content, … Read more
The workhorse is WP_Theme::get_page_templates() (wrapped by the helper function get_page_templates()). If you check out the source, you’ll see: /** * Filter list of page templates for a theme. * * @since 3.9.0 * @since 4.4.0 Converted to allow complete control over the `$page_templates` array. * * @param array $page_templates Array of page templates. Keys are … Read more