• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Translating Page To Genesis

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Translating Page To Genesis

This topic is: not resolved

Tagged: custom, loop, page, query, template

  • This topic has 1 reply, 1 voice, and was last updated 11 years, 3 months ago by Porter.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • July 27, 2014 at 9:15 am #115981
    Porter
    Participant

    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 🙂


    Buy me a beer? | Try DigitalOcean VPS Hosting

    http://anightinburlington.com/bars
    July 27, 2014 at 3:08 pm #116024
    Porter
    Participant

    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(); ?>

    Buy me a beer? | Try DigitalOcean VPS Hosting

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble