How can I make my custom templates respect permissions?

Message you quoted is being generated by members_content_permissions_protect() function. By default it is used as a filter on the_content() and the_excerpt() functions. Since your custom template doesn’t use these – there is no case for function to run. Try something like this in template: $content=”Content to protect”; echo members_content_permissions_protect( $content ); Another idea: $protected = … Read more

How to move style from template file to section?

What about putting styles before the function get_header(); <style type=”text/css”>#header { display: none; }</style> <?php get_header();?> <div class=”main-container-of-my-template”></div> <?php get_footer(); ?> However this is not recommended as it loads the styles even before the <html> not within the <head> section of your website, but as per your requirement this could be the only way to … Read more

Set template based on query in URL

There are a number of template filters available to override template selection. For a single post you can use the single_template filter: function wpa_single_template( $template ) { if( isset( $_GET[‘template’] ) ) { $template = locate_template( $_GET[‘template’] . ‘.php’, false ); } return $template; } add_filter( ‘single_template’, ‘wpa_single_template’ );

How to display error on specific template?

@PieterGoosen gave some good advice. Focus on that, But if you really wan it, then you can set debug ON temporarily on your website this way. In your wp-config.php use this instead. if ( isset( $_GET[‘debug’] ) && ‘debug’ == $_GET[‘debug’] ) { define( ‘WP_DEBUG’, true ); } Then access your website homepage/any page and … Read more

Change directory where get_header(), get_footer() and get_sidebar() look for templates

Simple solution, use get_template_part(). For example: get_template_part( ‘partials/footer’ ); Which would get the footer.php inside the partials/ directory. Another example: get_template_part( ‘partials/footer’, ‘home’ ); Which would get the footer-home.php inside the partials/ directory. One more example: get_template_part( ‘partials/footer/blog’ ); Which would get the blog.php inside the partials/footer/ directory.

Load template file without a post type

You could setup a custom rewrite rule using add_rewrite_rule and send these requests to a custom page. Your URL structure could be /index-page/single-event-slug The rule would point all of the single events to a separate page where you can then set your template events-single.php. Another option is to pass the events in as a query … Read more

Child theme TEMPLATEPATH issue

In your context you use the wrong constant. You must use the constant STYLESHEETPATH for the path to the active child theme. The constant TEMPLATEPATHget the path to the parent theme, that was referenced in the child theme. But, a important hint. The constant is deprecated, see the ticket #18298 for more information. That’s is … Read more