Is there a way to set different post templates for parent posts and child posts in the same post type?

Simplest way is to use single_template filter hook (one of the {$type}_template hooks). It is fired by WordPress to filter the template file found for singular post requests. add_filter(‘single_template’, function($template) { $queried = get_queried_object(); if ( $queried->post_type === ‘clients_projects’ ) { // only for this CPT // file name per OP requirements $file=”clients_projects_”; $file .= … Read more

Custom post type templating problem

Archive pages A & B already exist as your brand and type term archives, you can style those differently by creating taxonomy-brand.php and taxonomy-type.php templates. The remaining piece is two different single product views. The simplest way to achieve that would be to append a GET var onto the permalinks: http://domain.com/product/someproduct/?origin=brand http://domain.com/product/someproduct/?origin=type WordPress has the … Read more

Manipulating show_on_front, page_on_front, page_for_posts and template hierarchy

Ok, got it working. I was returning a property of a serialized option within the callbacks for the filters: add_filter(‘pre_option_page_on_front’, ‘page_on_front’); function page_on_front() { $options = get_option(‘theme_options’); return $options[‘page_on_front’]; } add_filter(‘pre_option_page_for_posts’, ‘page_for_posts’); function page_for_posts() { $options = get_option(‘theme_options’); return $options[‘page_for_posts’]; } The returend values were numbers, but strings. Typecasting them to int got it working.

Display Categories, Sub-categories, and Sub-sub-categories on separate pages

If I understand correctly, it certainly is possible. I would start with the function that determines if current category has parent or not. function category_has_parent($catid){ $category = get_category($catid); if ($category->category_parent > 0){ return $category->category_parent; } return false; } In the PHP template that displays your FAQ I would check if current category has parent (if … Read more

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