I am using query_posts to combine two posts categories on a page (by inserting this simple php script on the page using a plugin). This script gives me all the posts I want, however one of the categories has some extra custom fields using another plugin (CFS). The plugin has an api to get all fields and values by post id, I want to be able to loop through the wp posts array and add the custom fields where appropriate but I don't know much about wordpress and all the options and different ways of doing the same thing are confusing. I tried to use a wp_query but couldnt get it to work. Is it possible to use query_posts to not automatically add to the webpage but loop through the items so I can add some extra elements?
Edit: To clarify, I am looking for an alternate way to display the posts than add_post_content. I would like to basically make my own version of it, but in each loop also check for the extra fields and add those where appropriate. Is there an alternate to add_post_content like that/a way to get an array of posts rather than display the posts?
$paged = ( get_query_var('paged') ? get_query_var('paged') : 1);
//adds all posts to page. Is there a way to get the posts but not add to page automatically?
$posts = query_posts( array( 'category__in' => array(152,1), 'posts_per_page' => 5, 'orderby' => 'DATE', 'order' => 'DESC', 'paged' => $paged,) );
foreach ($posts as $post){
if($posts->cat_id = $target_category){ //pseudocode, if post category is cat with extra fields
$fields = CFS()->get( False, $post->ID); //this line gives array of meta fields and values.
add_fields_to_div(); //pseudocode, if target cat add custom field data
}
add_post_content(); //add the content from $post
}
the_posts_pagination( ); //paginate