Search breaks when querying main loop for category

For your second example, I think you’re initiating your Loop incorrectly. You’re declaring $query, which hasn’t been globalized? // Search is working, querying is not global $query_string; // required $posts = query_posts($query_string.’&posts_per_page=3&cat=$catid’); while ( $query->have_posts() ) : $query->the_post(); Try omitting $query from your Loop initiation? // Search is working, querying is not global $query_string; // … Read more

Custom Query num_rows returns wrong amount

If you want the total count of all the published posts in a particular category you can try this. $all_posts = new WP_Query( array( ‘posts_per_page’ => -1, ‘post_status’ => ‘publish’, ‘cat’ => 3 ) ); echo $all_posts->post_count; or $all_posts = new WP_Query( array( ‘posts_per_page’ => -1, ‘post_status’ => ‘publish’, ‘category_name’ => ‘uncategorized’ ) ); echo … Read more

Category Foreach keeps looping?

<?php $cats = get_categories(‘child_of=”.get_query_var(“cat’)); foreach ($cats as $cat) : $args = array( ‘posts_per_page’ => 3, // max number of post per category ‘category__in’ => array($cat->term_id) ); $my_query = new WP_Query($args); if ($my_query->have_posts()) : echo ‘<h3>’.$cat->name.'</h3>’; while ($my_query->have_posts()) : $my_query->the_post(); ?> <?php /*general loop output; for instance: */ ?> <a href=”https://wordpress.stackexchange.com/questions/42272/<?php the_permalink() ?>”><?php the_title(); ?></a> <br … Read more

get custom post type

Using query_posts() you can pass ‘post_type=custom-post-type’ it will however not work with a category associated with default posts but instead you can pass the custom taxonomy name are the value taxonomy=taxonomy_value You’ll need to do something like: query_posts(array(‘post_type’ => ‘customposttype’, ‘posts_per_page’ => 72, ‘custom_taxonomy_name’ => ‘custom_taxonomy_value’, ‘order’ => ‘ASC’));

Possible to display posts containing a short code ?

Taxonomy Query Always use get_posts() for sidequeries. query_posts() is only for the Main query and new WP_Query() should be used for the second queries only. Read more here. You can query posts by a taxonomy (category, term, etc.): $cat_posts = new WP_Query( array( ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘movie_janner’, ‘field’ => … Read more

Displaying terms based on loop posts?

I think you can try the following options. wp_list_categories with the ‘show_count’ parameter http://codex.wordpress.org/Template_Tags/wp_list_categories get category and use $count = $category->category_count; http://codex.wordpress.org/Function_Reference/get_category You can traverse up the functions to get_term if those don’t work and see what is in there, even though you probably can use get the terms you will have to parse the … Read more

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