pherank
Member
Posted 8 months ago #
I would love to know why the results from this query only displays a single post, even though each ID is valid, and using either of the single IDs will display the appropriate post for that ID.
<?php /* Remove category 5 from Home and Archive page displays */ ?>
<?php
if ( is_home() || is_archive() ) {
global $query_string;
query_posts($query_string . '&cat=-5&p=273,225');
}
?>
Try
global $wp_query;
$args = array_merge(
$wp_query->query,
array(
'post__in' => array( 273, 225 ),
'cat' => '-5'
)
);
query_posts( $args );
pherank
Member
Posted 7 months ago #
Thanks Nate: that does work. But now I'm realizing that I needed to use the query string syntax so that I could override a WP plugin (w/ aspo=vanilla):
query_posts($query_string . '&cat=-5&p=273,225&aspo=vanilla');
But for whatever reason only the first ID number is displayed. Arrrgh.
This won't work?
global $wp_query;
$args = array_merge(
$wp_query->query,
array(
'post__in' => array( 273, 225 ),
'cat' => '-5',
'aspo' => 'vanilla'
)
);
query_posts( $args );
The p argument can only take a single ID.
http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters
pherank
Member
Posted 7 months ago #
Thanks, that explains it. It would have to be handled as an array.