web-profile

Query

You can write like this:

query_posts('cat=55&author=77');

or like this:

query_posts(array(
  'cat' => 55,
  'author' => 77,
) );

or like this:

$new_query['cat'] = 55;
$new_query['author'] = 77;
query_posts($new_query);

If you are working with $query_string (needed for pagination for example) you can write like this (if you are working with string of parameters):

global $query_string;
parse_str( $query_string, $args );
$args['post_type'] = array( 'post', 'video' );
query_posts( $args );

or like this:

global $query_string;
query_posts( $query_string . '&order=ASC' );

or like this (if you are working with array of parameters):

global $wp_query;
$args = array_merge( $wp_query->query, array( 'post_type' => 'product' ) );
query_posts( $args );

or like this (if you are working with array of parameters):

$new_query = wp_parse_args($query_string);
$new_query['cat'] = 55;
$new_query['author'] = 77;
query_posts($new_query);

If you want to get your own post type:

<?php
$args=array(
'paged'=>$paged,
'posts_per_page'=>5,
'post_type'=> array( 'post', 'catalog_item' )
); 
query_posts($args);
if (have_posts()) : while (have_posts()) : the_post();
	?><a href="<?php the_permalink() ?>"><?php the_title() ?></a><br />
<?php
endwhile; endif;
wp_reset_query();
?>

Leave a Reply

Your email address will not be published.