Tweaking Genesis Template

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)

These forums are closed to new replies / tickets. Please open a support ticket from our new Support page.

  • Author
    Posts
  • #5332
    Alan
    Spectator

    Hi Merv,

    As far as I can see the single template is applied a little late (inside the loop) to actually be able to add any genesis custom tweaking. Whilst much of that can be done in functions.php with
    if (singular('rental') || if singular(' ... )

    Some of my site design requires a bit more drastic restructuring, which I believe can be only achieved in the genesis/single-listing.php

    I have found a way to overide this (genesis template location), firstly this can be put in wp-config
    define ('EPL_PATH_TEMPLATES_POST_TYPES_GENESIS','mycustompath/');

    But that is a bit hardcoded.

    A more generic solution is the use the filter
    add_filter( 'template_include', 'epl_load_core_templates' );

    I’m sharing this for two reasons, 1) did I miss something obvious in template overriding and
    2) if my solution is actually valid (it works) it might help others searching for code snippets

    And the code I used was

    // force local  templates
    add_filter( 'template_include', 'wsl_load_core_templates' );
    function wsl_load_core_templates($template) {
    
    	if ( epl_is_genesis_framework_theme() ) {	
    		$template_path = get_stylesheet_directory() . '/genesis/';
    	} else {
    	    return $template;
    	}
    	$post_tpl	=	'';
    	$epl_posts 	= array( 'property' , 'land' , 'rental' , 'rural' , 'commercial' , 'business' , 'commercial_land' );
    	
    	if ( is_single() && in_array( get_post_type(), $epl_posts ) ) {
    	
    		$common_tpl		= 'single-listing.php';
    		$post_tpl 		= 'single-'.get_post_type().'.php';
    		$find[] 		= $post_tpl;
    		$find[] 		= epl_template_path() . $post_tpl;
    		$find[] 		=  $common_tpl;
    		$find[] 		= $common_tpl;
    		$find[] 		= epl_template_path() . $common_tpl;
    		
    	} elseif ( is_post_type_archive( $epl_posts ) ) {
    		$common_tpl		= 'archive-listing.php';
    		$post_tpl 		= 'archive-'.get_post_type().'.php';
    		$find[] 		=  $post_tpl;
    		$find[] 		= epl_template_path() . $post_tpl;
    		$find[] 		=  $common_tpl;
    		$find[] 		= epl_template_path() . $common_tpl;
    		
    	} elseif ( is_tax ( 'location' ) ) {
    
    		$term   		= get_queried_object();
    		$common_tpl		= 'archive-listing.php';
    		$post_tpl 		= 'taxonomy-' . $term->taxonomy . '.php';
    		$find[] 		= 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
    		$find[] 		= epl_template_path() . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
    		$find[] 		= 'taxonomy-' . $term->taxonomy . '.php';
    		$find[] 		= epl_template_path() . 'taxonomy-' . $term->taxonomy . '.php';
    		$find[] 		= $common_tpl;
    		$find[] 		= $post_tpl;
    		$find[] 		= epl_template_path() . $common_tpl;
    
    	}
    	
    	if ( $post_tpl ) {
    		$template       = locate_template( array_unique( $find ) );
    		if(!$template) {
    			$template	=	$template_path . $common_tpl;
    		}
    	}
    	return $template;
    
    }

    (and of course copying teh genesis templates to a directory called genesis in the stylesheet directory)

    • This topic was modified 9 years, 2 months ago by Alan.
    #5508
    Merv Barrett
    Keymaster

    What functionality are you attempting to add from Genesis?
    – I’m an iThemes Builder guy myself.

    Can you setup a test site and explain specifically what you are trying to add?

    We can then add the necessary filters to the core Or if something is wrong and needs fixing 🙂

    #5541
    Merv Barrett
    Keymaster

    Sorry Alan, this topic has been moved to theme support.

These forums are closed to new replies / tickets. Please open a support ticket from our new Support page.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Theme Support’ is closed to new topics and replies.