count not working as planned


#1

[php]<?php foreach (get_terms('actor') as $cat) : ?>

<?php $args = array( 'post_type' => 'movies', 'orderby' => 'title', 'order' => 'DESC', 'tax_query' => array( array( 'taxonomy' => 'actors', 'field' => 'slug', 'terms' => array( $cat ), ), ), ); $query = new WP_Query( $args );
				$count = $query->found_posts;			

			?>
			
				<a href="?$cat->name;"><?php echo $cat->name; ?></a> <span style="color: white"><?php echo $count; ?></span>
				
			</div>
			
			<?php endforeach; ?>[/php]

Why is it the count process does not work?

Just trying to list all actors and the amount of movies they are associated with.

please help


#2

I think that you will find that it should be

[php]
$count = $query->post_count;
[/php]


#3

May I ask a question relative to this one? if the answer is yes please read on…
I have just recently added a page to my wordpress installation page-actor.php, where I intended to list all the actors that I have on my db and with the movie count associated with them. I have successfully done this but to my dismay I cannot paginate or set posts_per_page, Ideally I would want it paginated a letter as a time e.g. a, b, c…
…if answer is no discard the previous statements


#4

You probably can but it will need significant custom coding or maybe even a plugin. The pagination codes I have seen for Wordpress just make use of paged in the query.

However have you considered just doing it with links and putting a filter on your query for just the surname letter? Probably easier.


#5

considered yes but coding more difficult as I have no formal php or wp training.
as for plugins … way beyond me sorry


#6

If you don’t have the skills then this is probably something that you will have to hire someone to do for you.

Doing a Google search turns up several posts on Stackexchange on how to do it and also this plugin https://wordpress.org/plugins/alphabetic-pagination/ that looks as though it is easy to use.


#7

would you code something for me?


#8

No sorry the idea of this group is for you to attempt it yourself and when you run into problems then ask for specific help. Use it as a learning opportunity. There are various freelance sites where you will find help for a fee if you don’t want to attempt it yourself.