wordpress 3.4 template files in subdirectories

The solution shared in this answer on StackOverflow works for me: https://stackoverflow.com/questions/4647604/wp-use-file-in-plugin-directory-as-custom-page-template#answer-8255556 function get_book_post_type_template($single_template) { global $post; if ($post->post_type == ‘books’) { $single_template = dirname( __FILE__ ) . ‘/themefiles/single-books.php’; } return $single_template; } add_filter( “single_template”, “get_book_post_type_template” ) ;

Custom Post Type .current-menu-item not applying on Custom Post Type Archive Page

I found an answer by searching in similar posts and links. I added a line to fit my needs (I wanted to prevent my blog page to get highlited when on a custom post).See this line: unset($classes[array_search(‘current_page_parent’,$classes)]); Solution function add_parent_url_menu_class( $classes = array(), $item = false ) { // Get current URL $current_url = current_url(); … 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.

WordPress Template Hierarchy

You can use the dynamic filter {type}_template (where {type} is the current query type e.g. single, index etc.) found in get_query_template(): function wpse_204848_get_id_template( $template ) { if ( $post = get_queried_object() ) { if ( $_template = locate_template( “single-{$post->post_type}-{$post->ID}.php” ) ) $template = $_template; } return $template; } add_filter( ‘single_template’, ‘wpse_204848_get_id_template’ ); For a portfolio … Read more

Remove header and footer but KEEP all css and js etc for a custom post template?

If someone needs something similar, I actually found an answer to my issue and it is to pass arguments to get_header() and get_footer(). <?php get_header(‘customposttype); ?> <div style=”width:500px;”> <?php $id = get_the_id(); echo do_shortcode( ‘[skwidget id=”‘ . $id . ‘”]’ ); ?> </div> <?php get_footer(‘customposttype’); ?> and copy header.php to header-{customposttype}.php and footer.php to footer-{customposttype}.php … Read more

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