# Pagination doesn't work when the post is a custom query with attachment posttype

**URL:** <https://forum.pinegrow.com/t/pagination-doesnt-work-when-the-post-is-a-custom-query-with-attachment-posttype/9031>\
**Category:** Pinegrow WP\
**Tags:** bootstrap5\
**Created:** [July 23, 2024, 1:37pm UTC](https://forum.pinegrow.com/t/pagination-doesnt-work-when-the-post-is-a-custom-query-with-attachment-posttype/9031 "2024-07-23T13:37:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazzel](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@mazzel](https://forum.pinegrow.com/u/mazzel)\
**Post date:** [July 23, 2024, 1:37pm UTC](https://forum.pinegrow.com/t/pagination-doesnt-work-when-the-post-is-a-custom-query-with-attachment-posttype/9031/1 "2024-07-23T13:37:18Z")

</div>

I am displaying all images from the media library.  
Since it are many images I want to paginate it  
Using Bootstrap 5, custom query, “the loop”. The Show Post action with a custom query doesn’t work with attachments, therefore I have to use The Loop…

What happens is that I see the first 3 items with pagination arrows, but when I click NEXT I still se the same 3 pictures like this

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/b/bf5df0f0fa00ad898e8a0f3c142d30af0a7827dd.jpeg)

Here you see the post content with the loop div and the pagination div, to give you a view what i am doing.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/a/a6fd48f052aa3ddefda0065e212c4e7383976cb6.png)

The loop looks like this, I could place all my args in this pinegrow action, so I dont need the “Args in own PHP block”

Here the parts of the screenshot for this The Loop action… doenst fit in one screenshot

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/c/c29c0ad77b145d41b1cee4f8c5a852d4039640ae.png)  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/a/a2c344ee8a4adf48a673913601197a092a4a6be1.png)  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/d/df397a1d81932501718171a7252aade46c052d95.png)  
Pls. ignore the 3 in the screenshot, posts per page, since it is overruled with: show all.

The pictures in the image library can have a category, and I gave some the category name: 3d.

If the main loop would be Show Posts and custom query, it wil not work with attachments.  
The page itself is: category-3d.php  
If I use show posts then it would print me Posts from 3d category, that is something else then 3d category in the media libaray images.

So maybe I shoud make a real attachment post page like in the hierarchy from WordPresss. The php file name should then be: attachment.php… but in WordPress I have no clue how I can show tht page since I cant make a menu item for that I think

Food for thought…

Pagination:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/0/0151336028a1125765f4a0edfa06453289be3589.png)

---

<div class="post-metadata">

**Author:** ![mazzel](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@mazzel](https://forum.pinegrow.com/u/mazzel)\
**Post date:** [July 23, 2024, 2:44pm UTC](https://forum.pinegrow.com/t/pagination-doesnt-work-when-the-post-is-a-custom-query-with-attachment-posttype/9031/2 "2024-07-23T14:44:01Z")

</div>

My issue with pagination I could discuss it before, see [Bootstrap 4 page pagination (Bug?)](https://forum.pinegrow.com/t/bootstrap-4-page-pagination-bug/6702)

---

<div class="post-metadata">

**Author:** ![mazzel](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@mazzel](https://forum.pinegrow.com/u/mazzel)\
**Post date:** [July 24, 2024, 7:27am UTC](https://forum.pinegrow.com/t/pagination-doesnt-work-when-the-post-is-a-custom-query-with-attachment-posttype/9031/3 "2024-07-24T07:27:07Z")

</div>

another note: Since Wordpress 6.4, attachment pages are fully disabled in Wordpress.  
Ref: [Changes to attachment pages – Make WordPress Core](https://make.wordpress.org/core/2023/10/16/changes-to-attachment-pages/)

This shouldn’t interfere with my issue, it is just a note for those who want to make an attachment page. You can enable it, therefore read the article.
