Community Forums › Forums › Archived Forums › General Discussion › Custom loop
Tagged: loop
- This topic has 5 replies, 3 voices, and was last updated 9 years, 7 months ago by Blenderbox.
-
AuthorPosts
-
September 8, 2014 at 2:52 am #123312BlenderboxMember
Hi,
I'm using wp-property plugin and the default properties template has an ajax pagination that doesn't work with genesis. I've asked in the support forum but they don't answer me, so I'm trying to list all the properties in a template with custom loop and genesis pagination.
The problem is that I can only get the property attributes using get_posts() function, but then the pagination is not working.
function custom_loop() { $args = array( 'post_type' => 'property', 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page'=> 6, 'paged' => get_query_var( 'paged' ) ); $items = get_posts( $args ); if( $items ) { ?> <div class="property_row"> <div class="all_properties"> <?php foreach( $items as $item ) { ?> <div class="property"> <div class="property_thumb"> <div class="property_image"> <a href="<?php echo get_permalink( $item->ID ); ?>" title="<?php the_title_attribute(); ?>" class="property_overview_thumb property_overview_thumb_property thumbnail" rel="properties"> <?php echo get_the_post_thumbnail( $item->ID, 'property' ); ?> <div class="portfolio_image_fadder"></div></a> </div> </div> <div class="property_info"> <div class="property_overview"> <div class="property_title"> <a <?php echo $in_new_window; ?> href="<?php echo get_permalink( $item->ID ); ?>"><?php echo get_the_title( $item->ID, 'property' ); ?></a> </div> <div class="property_price"><?php echo $item->price; ?></div> <div class="area"><?php echo $item->area; ?></div> <div class="bedrooms"><?php echo $item->bedrooms; ?></div> <div class="bathrooms"><?php echo $item->bathrooms; ?></div> <?php if($item->sold == 'Yes'): ?><div class="sold"><?php echo $item->sold; ?></div><?php endif; ?> </div> </div> </div> <?php } genesis_posts_nav(); ?> </div> </div> <?php } wp_reset_query(); }
If I use the classic loop I get the images, titles and pagination but I don't know how to get the attributes.
function custom_loop() { $args = array( 'orderby' => 'post_date', 'post_type' => 'property', 'order' => 'DESC', 'posts_per_page'=> 6, 'paged' => get_query_var( 'paged' ) ); global $wp_query; $wp_query = new WP_Query( $args ); if( $wp_query->have_posts() ) {?> <div class="property_row"> <div class="all_properties"> <?php while( $wp_query->have_posts() ): $wp_query->the_post(); global $post; ?> <div class="property"> <div class="property_thumb"> <div class="property_image"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" class="property_overview_thumb property_overview_thumb_property thumbnail" rel="properties"> <?php echo genesis_get_image( array( size => 'property' ) ); ?> <div class="portfolio_image_fadder"></div></a> </div> </div> <div class="property_info"> <div class="property_overview"> <div class="property_title"> <a <?php echo $in_new_window; ?> href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </div> <?php //foreach( $wp_query as $item ) { ?> <div class="property_price"><?php echo $item->price; ?></div> <div class="area"><?php echo $item->area; ?></div> <div class="bedrooms"><?php echo $item->bedrooms; ?></div> <div class="bathrooms"><?php echo $item->bathrooms; ?></div> <?php if($item->sold == 'Yes'): ?><div class="sold"><?php echo $item->sold; ?></div><?php endif; ?> <?php //} ?> </div> </div> </div> <?php endwhile; genesis_posts_nav(); ?> </div> </div> <?php } wp_reset_query(); }
If somebody could help me it will be awesome because I don't know what elese to try.
Thanks a lot!
September 8, 2014 at 3:19 am #123320Brad DaltonParticipantSeptember 8, 2014 at 11:18 am #123323BlenderboxMemberSeptember 10, 2014 at 1:45 am #123694BlenderboxMemberOk, now I see I can't post more than 2 links, I didn't know what was happening.
So the links to the two tests:
And the plugin properties page is in Porperties link on the main menu.
By the way, I just get an answer from the plugin forum and they says that I'm getting this error: 'You don't have permission to access /cms/wp-admin/admin-ajax.php on this server.' but they don't give me any solution. I don't understand how I can get that error only with genesis, and not with Twenty Fourteen theme.
Any idea?Thanks!
September 10, 2014 at 9:58 am #123750briansteelecaMemberI can see a problem with your classic loop: the variable
$item
doesn't exist.To get your properties I think you can use
get_post_meta()
:<?php $property_price = get_post_meta($post->ID, 'property_price', true); ?> <div class="property_price"><?php echo $property_price; ?></div>
September 11, 2014 at 3:57 am #123896BlenderboxMemberIt worked! Thanks a lot!!
-
AuthorPosts
- The topic ‘Custom loop’ is closed to new replies.