Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 112476

goldmember on "wp_query with custom fields"

$
0
0

i want to create a list of posts from category XYZ, and sort them alphabetically based on what's contained in the VALUE field of a custom field called "studentname“.

i tried this code and it didnt work. any idea what's wrong? thanks in advance.

<?php

  	$loop = new WP_Query( array(
    		'showposts' => 5,
    		'post_type' => 'studentname',
    		'category_name' => XYZ,
		'orderby' => 'meta_value',
		'meta_key' => 'studentname'
    		)
    		);
  	while ( $loop->have_posts() ) : $loop->the_post(); ?>
   	<div>
      		<h2><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    	</div>
  <?php endwhile; ?>

Viewing all articles
Browse latest Browse all 112476

Trending Articles