• 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

Custom loop

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 › General Discussion › Custom loop

This topic is: resolved

Tagged: loop

  • This topic has 5 replies, 3 voices, and was last updated 11 years, 9 months ago by Blenderbox.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • September 8, 2014 at 2:52 am #123312
    Blenderbox
    Member

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

    Screenshot

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

    screenshot

    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 #123320
    Brad Dalton
    Participant

    Link to the site please.


    Tutorials for StudioPress Themes.

    September 8, 2014 at 11:18 am #123323
    Blenderbox
    Member

    Default plugin properties page:

    First template test:

    Second template test:

    Thanks!

    September 10, 2014 at 1:45 am #123694
    Blenderbox
    Member

    Ok, 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:

    Without pagination

    Without attributes

    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 #123750
    briansteeleca
    Member

    I 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 #123896
    Blenderbox
    Member

    It worked! Thanks a lot!!

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Custom loop’ is closed to new replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 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