Select category in custom query

I would do this in two pieces. Add this into your functions.php file to grab custom fields globally: function get_custom_field($key, $echo = FALSE) { global $post; $custom_field = get_post_meta($post->ID, $key, true); if ($echo == FALSE) return $custom_field; echo $custom_field; } Build your query as follows: I can’t seem to get markdown to play nice, so … Read more

How to display posts from a single category within a custom taxonomy

I believe your looking for something like this <?php $args = array( ‘posts_per_page’ => 1, ‘post_type’ => ‘inventory’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘inventory-category’, ‘field’ => ‘slug’, ‘terms’ => array( ‘bulk-racks’ ) ) ) ); query_posts( $args ); while ( have_posts() ): the_post(); // do stuff here ?> <?php endwhile; ?> Heres how to … Read more

Query on custom field count?

The following code allows you to add the parameters wpse4528_key and wpse4528_minimum to your queries, and will then add an extra criterium to the where clause that counts the number of meta values with your key. add_filter( ‘posts_where’, ‘wpse4528_posts_where’, 10, 2 ); function wpse4528_posts_where( $where, &$wp_query ) { global $wpdb; $count_key = $wp_query->get( ‘wpse4528_key’ ); … Read more

Filter query_posts by tag slug on “Tag Archive” page (when tag is 2 or more words)

The single_tag_title() function returns the tag title while you need the tag slug or ID for use in query_posts(). This should get you started: if ( is_tag() ) { $tag = get_queried_object(); $tag_title = $tag->name; // Same as single_tag_title() $tag_slug = $tag->slug; $tag_id = $tag->term_id; } http://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters

query_posts sort in multiple directions

OrderBy The query functions, like get_posts(), query_posts() call a new WP_Query inside – they’re just wrappers. The more important thing is what goes on in the class WP_Query. Specifically inside WP_Query -> get_posts(). When you add an orderby argument, then the following happens: WP checks if it set. If not, then it uses the $wpdb->posts.post_date … Read more

Query not returning CPT posts

I had a similar problem and posted the solution here: http://wordpress.org/support/topic/role-scoper-updating-query_posts query_posts causes the main WP_Query to be discarded. That may or may not be the behavior you want. If no, you need to update WP_Query, then you could update your functions.php file to include a register filter that displays your content types as part … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)