This is my first post on stack overflow!
I am a WordPress beginner and have almost completed developing my first theme that involves using basic property listings.
I have already tried to solve this problem by checking here..
- http://codex.wordpress.org/Function_Reference/register_taxonomy
- http://codex.wordpress.org/Function_Reference/query_posts
..as well as many google searches. and I cant seem to find anything that will help me.
Im having trouble displaying posts from a custom post type called 'tfg-properties' in the order that i need them to appear.
Custom Taxonomy - 'featured-properties' - functions.php
register_taxonomy('featured-properties', 'tfg-properties', array(
"hierarchical" => true,
"label" => "Featured Properties",
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array(
'slug' => 'featured-property',
'with_front' => false ),
'public' => true,
'show_ui' => true,
'show_tagcloud' => true,
'_builtin' => false,
'show_in_nav_menus' => false)
);
I have created a custom taxonomy for this post type called 'featured-properties' what I want to do is have the posts from taxonomy - 'featured-properties' display before the other posts.
I am able to achieve this using categories but since I am also incorporating a blog this will not work..
Here is how I am querying my posts..
Query posts by category id - page.php
// Get all posts from featured properties
$catId = get_cat_ID('Featured Property');
query_posts('post_type=tfg-properties&cat=' . $catId);
// begin the loop
while( have_posts() ): the_post(); ?>
<li class="single-prop">
...
</li>
<?php endwhile; ?>
// Get all posts from featured properties
query_posts('post_type=tfg-properties&cat=-' . $catId);
// begin the loop
while( have_posts() ): the_post(); ?>
<li class="single-prop">
...
</li>
<?php endwhile; ?>
Is there any way I can sort the custom posts with custom tax to display before the other posts?
Thanks in advance!