Skip to content

A simple tutorial where you can display all your uploaded images in one WordPress gallery.

Notifications You must be signed in to change notification settings

fabian-website/wordpress-show-all-media-in-gallery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

WordPress: Show all uploaded images in one gallery

Here's a short tutorial how you can display all uploaded images in one WordPress gallery.

Simply put this code in each file you want to show the gallery like page.php in your theme-file.

<?php $args = array(
    'post_type' => 'attachment',
    'post_status' => 'published',
    'posts_per_page' =>-1,
    'numberposts' => null,
);

$attachments = get_posts($args);

$bilder = "";
if ($attachments) {
    foreach ($attachments as $attachment) {
        $id = $attachment->ID;
        $bilder = $bilder . $id . ", ";
    }   
} 
echo do_shortcode('[gallery include="'.$bilder.'" columns="3"]');
?>

You can change the value of columns in the line of the "do_shortcode" statement (line 24)

More infomation:

https://developer.wordpress.org/reference/functions/do_shortcode/

https://codex.wordpress.org/Class_Reference/WP_Query

About

A simple tutorial where you can display all your uploaded images in one WordPress gallery.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages