Echo the number of posts being displayed

rearrange your code and use post_count; example: <?php $movieNumber = 1; $today = date(‘Ymd’); $posts = array ( ‘post_type’ => ‘movie’, ‘posts_per_page’ => -1, ); $loop = new WP_Query( $posts ); ?> <div id=”posters<?php echo $loop->post_count; ?>”> <?php while ( $loop->have_posts() ) : $loop->the_post(); …etc…

Custom post query error

get_posts() doesn’t accept posts as input, it only takes argument to query posts. So it’s useless and breaking step in your process. It should work if you throw get_posts() out. See Displaying Posts Using a Custom Select Query in Codex for extensive writeup on custom queries. PS your query is seriously insecure, you need to … Read more

Get postlist for each category using query_posts?

Your use of queries is completely wrong, and as stated before, query_posts should never be used. The method you are using to retrieve you category ID’s are also a waste of resources. It would save much more if you knew the ID’s. I would also look at get_categories to retrieve my category details and passing … Read more

limit number of post for achive page

You should use the pre_get_posts filter for this. For example, you could do this in your theme’s functions.php file: function limit_category_posts( $query ) { if ( $query->is_archive() ) { // Do not do this for the date or category archives. if ( $query->is_date() || $query->is_category() ) return $query; if ( $query->query_vars[‘cat’] == 8 ) { … Read more

Query all post types but limit to parents

In your functions.php you can create a function that will hook into the pre_get_posts hook. Something like (just an example): function alter_query($query){ $query->set(‘post_parent’, 0); } add_action( ‘pre_get_posts’, ‘alter_query’ ); There you can alter the main query. That way while(have_posts()) : the_post(); will still just normally work. (You should check if you are altering the right … Read more

2 queries with counters

On the advise of Robert and Pieter I rewrote the loops using WP_Query instead of query_posts. It works now. Thanks guys. Here’s the code: <ul class=”tabs”> <li class=”tab-link current” data-tab=”tab-1″>Most Popular</li> <li class=”tab-link” data-tab=”tab-2″>Recent</li> </ul> <div id=”tab-1″ class=”tab-content current”> <div class=”slider”> <div class=”slide”> <?php $count = 0; $query = new WP_Query( array( ‘meta_key’ => ‘post_views_count’, … Read more

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