Query Loop: How to show number of total posts next to pagination

How can I show something like “Showing 12 of 25 posts”?

Can anyone reply? Is there a setting or built in element I haven’t found or is custom code required? If so can someone share some code please?

Thanks

Hi James,

Is this when using the Posts element or a Pagination element or something else?

How is the pagination currently being output?

Hi @Sridhar ,

I am using the Pagination element in the query loop but I can’t see anything in the Posts element either.

Would anyone be able to help?

I don´t think there is an in-built element that gives you that information. Instead WordPress has a function that can be use for this purpose:

You need to make a snippet of code, or maybe the code block of Bricks would help. Now I realized that using the dynamic content you can choose a function and give the parameters, not even need any snippet of code.

count_user_posts( int $userid, array|string $post_type = ‘post’, bool $public_only = false )

The post probably is “post”, because as you know it could be other CPT, and the"int $usedid probably you want the author or admin if there are not more users (anyway this can be entered as a dynamic content. The other parammeter leave it blank.

So go to dynamic content and choose php function, and enter this:

count_user_posts

and as parammeters: $userid
userid has to be the id of the author, which you can check your profile

Sorry if cannot help you more

Thank you for the suggestion @rjaureg but that function doesn’t refer to the query loop I am using on the page. I am also filtering using S&F Pro but bizarrely that doesn’t offer a count of viewable posts either.

Ok so you want to count the number of post of the specific loop? So if there is not that, the better is to make the loop on a php code…

That sort of defeats the purpose of the query loop builder. I don’t mind adding some PHP code or a shortcode element but I would like to know how to access the query loop object in the page

1 Like

Yeah the better would be if we have access to the code

Bricks has a few built-in functions for this, Bricks Builder Useful Functions And Tips - Pure Coding Knowledge Sharing Blog