Featured Posts for Category Pages

assign the additional category ‘featured’ to the post in the category ‘medical’. in your category template, use a query with ‘category__and’ => array(3, 27) example (assuming ‘medical’ is cat 3, and ‘featured’ is cat 27): <?php $args = array( ‘category__and’ => array(3, 27), ‘posts_per_page’ => 1 ); $feature = new WP_Query( $args ); if( $feature->have_posts() … Read more

Custom Post Type sorted by Title

Try… add_filter(“posts_orderby”, “my_orderby_filter”, 10, 2); function my_orderby_filter($orderby, &$query){ global $wpdb; //figure out whether you want to change the order if (get_query_var(“post_type”) == “my_post_type”) { return “$wpdb->posts.post_title ASC”; } return $orderby; }

Retrieve or Query Pages by ID

This is an inappropriate use of query_posts() which is only for modifying the main query for the page. Additionally, even if you change your snippet to use get_posts(), your template tags (e.g. the_excerpt()) won’t work as get_posts() isn’t a method of looping through posts, it just returns an array of posts. What you want is … Read more

How to Loop within a Loop (Display Children and then Grandchildren)

Try something like: <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <div class=”parent-post”> <?php the_title(‘<h2>’, ‘</h2>’); ?> <?php $children = new WP_Query( array(‘post_type’ => ‘page’, ‘post_parent’ => get_the_ID() )); ?> <?php if ( $children->have_posts() ) : ?> <ul class=”post-children”> <?php while ( $children->have_posts() ) : $children->the_post(); ?> <li><?php … Read more

Last posts from custom taxonomy

First you really shouldn’t use query_posts for that use get_posts or WP_Query and second tax_query accept an array of arrays from the codex: tax_query takes an array of tax query arguments arrays (it takes an array of arrays) so: $terms=get_terms(‘tax_name’); $request=array(); foreach((array)$terms as $t) $request[]=$t->slug; $tax_q = new WP_Query( array( ‘post_type’ => ‘post’, ‘posts_per_page’ => … Read more

Query_posts $query_string

After some searching I found the parameters I needed: https://gist.github.com/luetkemj/2023628 (on Line 231) //////Search Parameter //http://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter ‘s’ => $s, //(string) – Passes along the query string variable from a search. For example usage see: http://www.wprecipes.com/how-to-display-the-number-of-results-in-wordpress-search ‘exact’ => true, //(bool) – flag to make it only match whole titles/posts – Default value is false. For more … Read more

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