WordPress provides attachment pages out of the box. But is it somehow possible to have page with listing of all attachments that are connected to a certain post? It should basically work as a gallery overview. So this is not to be on the post page, but on its own.
1 Answer
You can. I think, you should do that with page-template
.
For that, create a page template. Easiest way is:
1) Inside your theme folder, make a duplicate of page.php
and name it i.e. my-page.php
2) open that file and in the top, after <?php
place this:
/**
* Template Name: my templt for attchmnts
*/
3) then just remove the content <div>
(you should determine that area) and place this code:
<?php
$attachments = get_posts( array(
'post_type' => 'attachment',
'parent' => $_GET['post_id'],
) );
foreach ( $attachments as $each ) {
echo 'Title is:' . $each->post_title . ' [content is]: ' . $each->post_content ."<br/><br/>";
}
?>
(This is just a skeleton, you should build other things yourself.)
then open a new page (i.e. exmaple.com/my_pageee
) and choose that template while publishing the page (under PUBLISH button). Then you should access that page like this:
example.com/my_pageee?post_id=436
so, you will get all attachments for post 436