Community Forums › Forums › Archived Forums › Design Tips and Tricks › Translating Page To Genesis
- This topic has 1 reply, 1 voice, and was last updated 8 years, 10 months ago by
Porter.
-
AuthorPosts
-
July 27, 2014 at 9:15 am #115981
Porter
ParticipantI'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 🙂
http://anightinburlington.com/barsJuly 27, 2014 at 3:08 pm #116024Porter
ParticipantWith 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(); ?>
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.