Sort / Order custom fields wordpress

Posted: October 14, 2013 in web

I had a custom field named “order”

...
$args = array(
	'post_type'		=> 'product',
	'posts_per_page'	=> -1,
	'meta_key'		=> 'order',
	'orderby'		=> 'meta_value_num',
	'order'			=> 'ASC'
);
$wp_query = new WP_Query( $args );                
                
                ?>
                <?php while (have_posts()) : the_post(); ?>
                    <div class="collection">
                      <div class="collection-thumbnail-container">
                        <?php if (has_post_thumbnail()) : ?>
                          <?php $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large'); ?>
                          <a rel="lightbox" href="<?php echo $large_image_url[0] ?>" title="<?php the_title_attribute('echo=0'); ?>">
                            <?php the_post_thumbnail('medium'); ?>
                          </a>
                        <?php endif ?>
                      </div>
                      <?php the_title('<h2><a href="#">', '</a></h2>'); ?>
                      <div class="content"><?php the_content(); ?></div>
                      <p><?php the_field('teaser'); ?></p>
		      <p>ddd<?php the_field('price'); ?>dd</p>
                      <?php edit_post_link(); ?>
                    </div>
                <?php endwhile; ?>

...
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s