Jump to content


Better, More Convenient, Private Support for Your iThemes Products Is Here.


We're moving support away from the forum and in to private tickets - Log In to Get Support Here


Note: any currently open support threads in the community forum will stay open while we resolve them.

resolved

How To Change Product Order In Custom Category Template

product order custom category template

2 replies to this topic

#1 verityweb

verityweb

    Member

  • Members
  • Others: BackupBuddy, Toolkit
  • PipPip
  • 19 posts

Posted 23 July 2014 - 01:01 PM

I used the instructions here: ttp://ithemes.com/codex/page/Exchange_FAQs:_How_Do_I_Create_a_Custom_Product_Category_Page to create a custom category template and it worked great except that the order that I setup in Exchange Settings was not included.

I added the following custom query arguments to modify the order but the results are removing most of the products from the output including product images instead of merely changing the sort order.
		 <?php $args = array ('order' => 'ASC', 'orderby' => 'slug',);
		 $query = new WP_Query( $args );
		 if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?>
			
<?php it_exchange_set_product( $post->ID ); ?>
<?php it_exchange_get_template_part( 'content-store/elements/product' ); ?>	
	
		 <?php endwhile; ?>
		 <?php endif; ?>

How can I change the sort order?

#2 Ronald

Ronald

    Forum Admin

  • Administrators
  • Others: All Plugins, All Themes, Moderators, Webdesign
  • 33,342 posts

Posted 23 July 2014 - 01:26 PM

Hi,

the query you have set up is not selecting Exchange products specifically, so it's not the way to do this.

If the setup in the Exchange Settings isn't working, than I think that is the issue to focus on,

And you can always use the following code (and change to suit your needs) to change the Exchange products order:

function my_products_order( $query ) {
		
		$post_type = $query->get( 'post_type' );
		
		if ( !is_admin() && $post_type == 'it_exchange_prod' ) {
				$query->set( 'order', 'asc' );
		}
		
}
add_filter( 'pre_get_posts' , 'my_products_order' );

you should add this to at the end of your child theme's functions.php file, but before a closing ?>, if any

Ronald

Join the iThemes Builder Community on Google+.



To ensure that we can process your support request efficiently, ALWAYS include a link to your site, and/or the page your request is related to. Please also read the forum guidelines.



When asking your question/posting your request on the forum, please be as concise and specific as possible. The shorter your request, the more to the point, the more specific, the easier it will be for us to try and help out.


#3 verityweb

verityweb

    Member

  • Members
  • Others: BackupBuddy, Toolkit
  • PipPip
  • 19 posts

Posted 24 July 2014 - 05:28 AM

View PostRonald, on 23 July 2014 - 01:26 PM, said:

Hi,

the query you have set up is not selecting Exchange products specifically, so it's not the way to do this.

If the setup in the Exchange Settings isn't working, than I think that is the issue to focus on,

And you can always use the following code (and change to suit your needs) to change the Exchange products order:

function my_products_order( $query ) {
	
	 $post_type = $query->get( 'post_type' );
	
	 if ( !is_admin() && $post_type == 'it_exchange_prod' ) {
			 $query->set( 'order', 'asc' );
	 }
	
}
add_filter( 'pre_get_posts' , 'my_products_order' );

you should add this to at the end of your child theme's functions.php file, but before a closing ?>, if any

Ronald

Duh! How could I forget something so simple? :)

Thanks!

ks



Reply to this Topic


ATTENTION
If this topic is marked RESOLVED or INFORMATION, or if you are NOT experiencing EXACTLY the same issue, please start a new topic to provide the details of your problem. If the solution provided doesn't work for you, you should start a new topic. If you feel this thread contains relevant information, you may include a link to it in your new topic. To ensure that we can process your support request efficiently, ALWAYS include a link to your site, and/or the page your request is related to. When posting your question or request on the forum, please be as concise and specific as possible. The shorter and more to the point you can make your request, the better.

For BackupBuddy related issues, be sure to include the status log from your most recent backup.

CLICK HERE to start a new topic in the Exchange ecommerce plugin forum.


  



Also tagged with one or more of these keywords: resolved, product order, custom category template

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Better, More Convenient, Private Support for Your iThemes Products Is Here.


We're moving support away from the forum and in to private tickets - Log In to Get Support Here


Note: any currently open support threads in the community forum will stay open while we resolve them.