Translating Page To Genesis

Community Forums Forums Design Tips and Tricks Translating Page To Genesis

This topic is: not resolved

This topic contains 1 reply, has 1 voice, and was last updated by  Porter 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #115981

    Porter
    Member
    Post count: 147

    I’m trying to translate my “directory listing” pages (shows all bars, restaurants, etc) to Genesis, and while I’m nearly there, still have formatting issues. I made a custom page template named directory_listing.php. Below is the original code, with my new code after:

    Original Code

    <?php
    /**
    * Template Name: Directory Listing
    */
    
    get_header();
    ?>
    <div class="span-24" id="contentwrap">
    
    	<div id="content">
    	
    		<?php if ( function_exists('yoast_breadcrumb') ) {
    				yoast_breadcrumb('<p id="breadcrumbs">','</p>');
    		} ?>
    
    		<?php 
    		
    		$this_page_title = get_the_title();
    		
    		$args = array(
    			'sort_order' => 'ASC',
    			'sort_column' => 'post_title',
    			'meta_key' => 'directory_category',
    			'meta_value' => $this_page_title,
    			'post_type' => 'page',
    			'post_status' => 'publish'
    		);
    		
    		$pages = get_posts($args); 
    		
    		if($pages) {
    		
    			foreach ($pages as $page) { ?>
    				
    				<div class="full-width-post" id="post-<?php $page->ID; ?>">
    					<?php echo(get_the_post_thumbnail($page->ID, array(260,200),  array("class" => "alignleft post_thumbnail"))); ?>
    					<h2 class="title" id="post-<?php $page->ID; ?>"><a href="<?php echo(get_permalink($page->ID)); ?>" rel="bookmark" title="<?php echo(get_the_title($page->ID)); ?>"><?php echo(get_the_title($page->ID)); ?></a></h2>
    					
    					<div class="directory-entry">
    					<?php echo(get_post_meta($page->ID, '_yoast_wpseo_metadesc', true)); ?>
    					</div>
    				</div>
    			<?php
    			}
    		}
    	?>
           
    	</div>
        
    </div>
    <?php get_footer(); ?>
    
    <!-- get_the_ID()  -->

    New Genesis Code

    <?php
     
    /**
    * Template Name: Directory Listing
    * Description: Used for "directory" pages.
    */
     
    // Add our custom loop
    add_action( 'genesis_loop', 'directory_listing_loop' );
     
    function directory_listing_loop() {
     
    	$this_page_title = get_the_title();
    		
    		$args = array(
    			'sort_order' => 'ASC',
    			'sort_column' => 'post_title',
    			'meta_key' => 'directory_category',
    			'meta_value' => $this_page_title,
    			'post_type' => 'page',
    			'post_status' => 'publish'
    		);
     
    	$pages = get_posts($args); 
    		
    		if($pages) {
    		
    			foreach ($pages as $page) { ?>
    				
    				<div class="full-width-post" id="post-<?php $page->ID; ?>">
    					<?php echo(get_the_post_thumbnail($page->ID, array(260,200),  array("class" => "alignleft post_thumbnail"))); ?>
    					<h2 class="title" id="post-<?php $page->ID; ?>"><a href="<?php echo(get_permalink($page->ID)); ?>" rel="bookmark" title="<?php echo(get_the_title($page->ID)); ?>"><?php echo(get_the_title($page->ID)); ?></a></h2>
    					
    					<div class="directory-entry">
    					<?php echo(get_post_meta($page->ID, '_yoast_wpseo_metadesc', true)); ?>
    					</div>
    				</div>
    			<?php
    			}
    		}
     
    	wp_reset_postdata();
     
    }
     
    genesis();

    What this does, is gather all pages (not posts) with the custom field and key of “directory_listing” and “bars”. The “bars” portion is dynamic, as it grabs the name of the page, and uses it as the key, so a bar page will show all bars, a restaurant page all restaurants, etc etc. I used a custom field, so that I could assign the pages more than one category (like you can with posts), allowing businesses to show up in multiple locations (bars and restaurants, for instance).

    The issue I’m having, is that the content is below the actual page area (there’s no background, it’s below the content area), and I’m not sure how to go about fixing that. I’m sure it’s very simple css / genesis knowledge I’m lacking, but I’m lost. If anyone could help me with that, and potentially clean up my code with any Genesis specific functions that could optimize things, that would be great! Let me know if you need any more information :)


    iNeedHelp ? helping = false : helping = true;

    http://anightinburlington.com/bars
    #116024

    Porter
    Member
    Post count: 147

    With some more reading, I’ve nearly managed to acquire what I was going for. The only real issue now, is that the content has no background. The background used for sidebar, and content / entry area doesn’t appear. I’m not sure how to change my code to include this.

    Any idea why the main background isn’t showing up behind my content on this custom template?

    Updated Genesis Code

    <?php
     
    /**
    * Template Name: Directory Listing
    * Description: Used for "directory" pages.
    */
     
     //Remove original  loop
     remove_action( 'genesis_loop', 'genesis_do_loop' );
     
    // Add our custom loop
    add_action( 'genesis_loop', 'directory_listing_loop' );
     
    function directory_listing_loop() {
     
    	$this_page_title = get_the_title();
    		
    		$args = array(
    			'sort_order' => 'ASC',
    			'sort_column' => 'post_title',
    			'meta_key' => 'directory_category',
    			'meta_value' => $this_page_title,
    			'post_type' => 'page',
    			'post_status' => 'publish'
    		);
     
    	$pages = get_posts($args); 
    		
    		if($pages) {
    		
    			foreach ($pages as $page) { ?>
    				
    				<div class="full-width-post" id="post-<?php $page->ID; ?>">
    					<?php echo(get_the_post_thumbnail($page->ID, array(260,200),  array("class" => "alignleft post_thumbnail"))); ?>
    					<h2 class="title" id="post-<?php $page->ID; ?>"><a href="<?php echo(get_permalink($page->ID)); ?>" rel="bookmark" title="<?php echo(get_the_title($page->ID)); ?>"><?php echo(get_the_title($page->ID)); ?></a></h2>
    					
    					<div class="directory-entry">
    					<?php echo(get_post_meta($page->ID, '_yoast_wpseo_metadesc', true)); ?>
    					</div>
    				</div>
    			<?php
    			}
    		}
     
    	wp_reset_postdata();
     
    }
     
    genesis(); ?>

    iNeedHelp ? helping = false : helping = true;

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

You must be logged in to reply to this topic.