sigil88
9/6/2016 - 8:27 PM

WP - wordpress loop - custom post type & wp_query()

WP - wordpress loop - custom post type & wp_query()

<?php
// set the wp_query
$args = array(
	'post_type'			=> 'job',
	'orderby'				=> 'menu_order',
	'order'				=> 'ASC',
	'no_found_rows'		=> true, //removes pagination
	'update_post_term_cache'	=> false,
	'post_per_post'		=> 50,
	'post_status'			=> 'publish'
	);

$jobListing	= new WP_Query( $args );
// print_r($jobListing);

<?php if ( $jobListing->have_posts() ) : ?>
			<p><?php _e('<strong>Note: </strong>This only affects the jobs listed using the shortcode functions.'); ?></p>
			
<!-- show the job posts in a list -->
<ul id="custom-type-list">
	<?php while ( $jobListing->have_posts() ) : $jobListing->the_post(); ?>
		<li id="<?php the_id(); ?>">
			<?php the_title(); ?>
		</li>
	<?php endwhile; ?>
</ul>

<!-- end show the job posts -->
<?php else : ?>
	<p><?php _e('You have no jobs to sort.', 'wp-job-listing'); ?></p>
<?php endif; ?>