Looper with wrong number of attachments

Hi,

I have built a looper to show all PDF attachments of a certain page.

The problem ist, that only 10 entries are output.

This is my query string:

post_type=attachment&post_mime_type= application/pdf&numberposts=-1&post_status=-1&post_parent={{dc:post:id}}

I did set “numberposts” to anything, but it stays the same.

When I change the value in Wordpress > Backend > Settings > Read > “Blog pages show a maximum of … posts” from 10 to to a higher value, then it works.

But this is not workaround, because on my blog page the number of posts changes, too, of course.

Hope you can see whats going on here.

Best regards and many thanks,
Hannes

Hello Hannes,

Thanks for writing to us.

In order to get all the posts I would suggest you please use the “posts_per_page” instead of the numberposts in your query string. If it doesn’t work for you, please share your details in a secure note. Please provide the following details

  • WordPress Login URL
  • Admin-level username and password
  • Exact page URL

You can find the Secure Note button at the bottom of your posts

Thanks

Thank you very much.
It was my blindness - posts_per_page did it.

Now one last question please:
Using the dynamic content, which one can I use to get the URL of the PDF attachment file?
My looper outputs all pdf media files that are attached to the current page.
This works fine.
Using {{dc:post:permalink}} outputs the link to the media attachment page, but not to the file itself.
Thank you & best regards,
Hannes

Hello Hannes,

Please use {{dc:looper:debug_consumer}} to find out the different field names that you can use to display the file attachment.

Best Regards.

Thank you very much, this is a really exciting and useful function!
It outputs the following value:
[“guid”]=>
string(108) “https://gymnasium-schoenefeld.salilou.com/wp-content/uploads/2023/10/FV-EGS-Elternbrief-Nr.-0-03.05.2018.pdf
This is exactly what I was looking for.
But when I call it with {{dc:post:guid}} it doesn’t output anything.
Unfortunately I couldn’t find any information about this in the forum or on the internet.
I could build it with {{dc:post:meta key="_wp_attached_file"}}, which outputs the relative path of the PDF file - at least that brings me much closer to the problem.
But it would be awesome to be able to build it using guid and generally use the keys from {{dc:looper:debug_consumer}}.
Best regards,
Hannes

Hello Hannes,

Try using {{dc:looper:field key="guid"}}, this should display the file URL.

Kindly let us know how it goes.

Thank you very much. Such a great feature!

You are most welcome.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.