I have the following code, which will print out articles that are posted in a special category called “Produkttest”. (I am using Magic Fields).
Now, I also want to include regular categories in this query, but is currently a little unsure how.
<ul> <?php $querystr = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'article_type' AND wpostmeta.meta_value = 'Produkttest' AND wposts.post_status = 'publish' AND wposts.post_type = 'post' ORDER BY post_date DESC "; $pageposts = $wpdb->get_results($querystr, OBJECT); if ($pageposts): foreach ($pageposts as $post): setup_postdata($post); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; endif; ?> </ul>
In the default WP-query I would have used this;
<?php query_posts(‘category_name=wordpress’); ?>
So, how can I do this inside my custom query?
- The topic ‘Custom query, select category’ is closed to new replies.