Query featured Posts
-
Hi there,
I have added page tagging to my site using the following code:
<?php add_action( 'init', 'create_mycustom_taxonomies', 0 ); function create_mycustom_taxonomies() { register_taxonomy( 'post_tag', 'page', array( 'hierarchical' => false, 'update_count_callback' => '_update_post_term_count', 'query_var' => false, 'rewrite' => false, 'public' => false, 'show_ui' => true, '_builtin' => true, ) ); } ?>
I have then proceeded to tag each of my project pages and now wish to make two separate wp_query posts – One of which needs to return the page which has been tagged ‘featured’…the other will return an array of pages that have a certain parent ID.
I have managed to get both queries working with one slight problem…the featured post is also being returned in the second query (because it is a child page of the parent ID).
I have tried many hacks to exclude the featured post from the other query but to no avail. Was wondering how to exclude the featured post from the other query and if there is a better way of setting this up to what i have at present.
Here is my code for the featured post query:
<?php query_posts(array('post_parent' => 36, 'posts_per_page' =>1, 'post_type' => 'page', 'tag' =>'featured'));?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?>
And the other query:
<?php query_posts(array('post_parent' => 36, 'posts_per_page' =>8, 'post_type' => 'page'));?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?>
Note; I replicate this on 4 different template pages, each quering a different post parent ID – again, is there a better way to go about this?
Many thanks in advance
- The topic ‘Query featured Posts’ is closed to new replies.