Community Forums › Forums › Archived Forums › Design Tips and Tricks › Weird loop behavior – Genesis child theme
Tagged: Custom Post Type, genesis, pagination
- This topic has 3 replies, 3 voices, and was last updated 9 years, 8 months ago by nuggetweb.
-
AuthorPosts
-
August 21, 2014 at 4:30 pm #120352nuggetwebMember
I'm using a custom post type ("attraction") with a Genesis child theme (education) and I'm having some really strange behavior with the loop.
I have it set to display 10 posts, which it does, but after the 3rd post the page alignment goes haywire and the posts start lining up against the left-hand side of the page. What's worse is that when you try to go to page 2 it just shows you the same posts as page 1.
This is the dev address where I'm having issues:
http://hcedc.nuggetweb.com/attraction/
Here is the template I'm using for the archive:
<?php /* Template Name: Attractions Template */ remove_action('genesis_loop', 'genesis_do_loop'); // Output our own post meta add_filter( 'genesis_post_info', 'attraction_post_archive_info' ); // Output for custom post type 'attraction' add_action('genesis_post_content', 'hcedc_attraction_filter_archive'); /** * Function that replaces the default loop * with a custom loop querying 'PostType' CPT. */ add_action('genesis_loop', 'gt_custom_loop'); function hcedc_attraction_filter_archive() { $addr1 = genesis_get_custom_field('hcedc_addr_text'); $city = genesis_get_custom_field('hcedc_city_text'); $phone = genesis_get_custom_field('hcedc_phone_text'); $zip = genesis_get_custom_field('hcedc_zip_text'); $post_meta = '<p class="hcedc">' . $city . '</p>'; $map_addr = $addr1 . "," . $city . ",IL," . $zip; $map = hcedc_google_map($map_addr,300,150); $table = $single . ' <table border="1"> <tr> <td style="vertical-align: top;">' . $map . '</td> </tr> </table> </div> '; echo $table; } function gt_custom_loop() { global $paged; $wp_query = null; $wp_query = new WP_Query(); $args = array('post_type' => 'attraction','orderby' => 'title', 'order' => 'ASC','paged='.$paged); // Accepts WP_Query args // (http://codex.wordpress.org/Class_Reference/WP_Query) genesis_custom_loop( $args ); } function attraction_post_archive_info() { $addr1 = genesis_get_custom_field('hcedc_addr_text'); $addr2 = genesis_get_custom_field('hcedc_addr2_text'); $city = genesis_get_custom_field('hcedc_city_text'); $zip = genesis_get_custom_field('hcedc_zip_text'); $phone = genesis_get_custom_field('hcedc_phone_text'); if ( !is_page() ) { return the_category(', '); } } genesis(); // <- everything important: make sure to include this. ?>
Any ideas where to turn? Thanks!
http://hcedc.nuggetweb.com/attraction/August 21, 2014 at 7:21 pm #120377Lauren @ OnceCoupledMemberFormatting: You have an unnecessary closing
div
in your code. Remove that! 🙂
We create mobile-first, PageSpeed-optimized, pixel-perfect custom themes! https://www.oncecoupled.com
August 21, 2014 at 7:53 pm #120384DTHkellyMemberDo you need the closing
?>
aftergenesis();
?August 21, 2014 at 8:21 pm #120387nuggetwebMemberThanks Lauren! The div was a left-over from a previously tried layout, but that did the trick.
I figured out the problem with the pagination as well. I was missing the posts_per_page, and I wasn't grabbing the page correctly.
I think everything is golden now. Thank you!
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.