WordPress Query Posts String & Array

Glenn Glenn's Blog 0 Comments

Here are a few ways to Query Posts in WordPress as a string and array:-


<?php query_posts('cat=-1&orderby=date&order=DESC&showposts=1'); ?>

Standard ‘Posts’


<?php $latesproducts = new WP_Query('posts_per_page=5&orderby=date&order=desc&post_type=wpsc-product'); ?>


	<?php
	$latesproducts = new WP_Query( array(
    'post_type' => 'wpsc-product',
    'post_status' => 'publish',
    'orderby' => 'date',
    'posts_per_page' => 5,
    'order' => 'ASC',
    'paged' => get_query_var('paged'),
));
?>

NB Above we are Querying WP E-Commerce Products as our Custom ‘Post Type’


	<?php
$args=array(
  'post_parent' => 106,
  'order'=>'ASC',
  'orderby'=> 'menu_order',
  'post_type' => 'page',
  'post_status' => 'publish',
  'posts_per_page' => 100
);
query_posts($args);
?>

Query Pages by menu order

About the Author
Wordpress Query Posts String & Array WordPress Query Posts String & Array 0da77002febbfe28d15144a57bbcc2c9 s 180 d mm r g

Glenn

A highly experienced WordPress Web Developer, Front-end and Back-end Developer & New Media Specialist with extensive knowledge of a wide spectrum of technologies in the Development and Creative Industries built up over a number of years.

Leave a Reply

Your email address will not be published. Required fields are marked *