Blog page won’t show Blog template

Based on your comment: 1) blog.php What is the file name of your blog custom page template? 2) home.php What is the file name of your front page custom page template? The answer is simple: The home.php file name is a reserved file name in the WordPress template hierarchy, and is used by the template … Read more

custom post template ignored after altering permalinks

Custom post types have a different hierarchy than pages or posts. They’ll use single-{{post_type}}.php and fall back to single.php. Post type archives will use archive-{{post_type}}.php and fall back to archive.php. Your question isn’t super clear, but if you want your custom post type’s singular page to use the page-testimonials.php template, rename it to single-testimonials.php. I … Read more

How to set up conditionals in page templates?

<?php /* Template Name:product */ get_header(); // check if product_id is not set or is empty string if( !isset($_GET[‘product_id’]) || ” == $_GET[‘product_id’] ) { // if so, run your query and display data $data = $wpdb->get_results(“myquery Here”); foreach($data as $row) { echo ‘<div>’; echo ‘<p>Name:’ . $row->p_name . ‘</p>’; echo ‘<p>Price:’ . $row->p_price. ‘</p>’; … Read more

Organize template parts and page templates in folders in regards of template hierarchy

Page templates are special case and since WP 3.4 can be put in subfolder natively. Other than that WP mostly expects flat file structure for templates. While template hierarchy is easily adjusted (see dynamic filter in get_query_template(), pretty much only thing needed)… From personal experience – overly extensive and nested directory structure for templates makes … Read more