Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9287819

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:46:04+00:00 2026-06-18T19:46:04+00:00

When i create a page, add a gallery, and browse this gallery on the

  • 0

When i create a page, add a gallery, and browse this gallery on the front-end it will browse all the attachments that are associated with that page, instead of just the images within that gallery. Is there a way to filter all the other attachments and only show the images within a certain gallery? So that, for instance, when I delete the gallery and add a new gallery on the same page > only the new gallery is shown?

Any ideas?

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T19:46:05+00:00Added an answer on June 18, 2026 at 7:46 pm

    This might not be the most elegant way, but i’ve found it very usefull.

    Passing a post ID to the function below will load a gallery from the post_content of that post. So you would create a gallery and insert it into your post content, then in the template you run this function and will be returned with an array of attachments in that gallery which you are free to to whatever with, i.e slideshows and the likes.

    function wp_load_gallery($post_id) {
      $post = get_post( $post_id );
      $regx = '/' . get_shortcode_regex() . '/';
      preg_match( $regx, $post->post_content, $matches );
      $ids = shortcode_parse_atts( $matches[3] );
    
      $gallery = array( );
      foreach( explode( ',', $ids['ids'] ) as $id ) {
        if($id) {
          $gallery[] = get_post( $id );
        }
      } 
    
      return $gallery;
    }
    

    Note that the shortcode is not cut from the content, so when you display the content you should run it through the strip_shortcodes function, i.e:

    echo strip_shortcodes( get_the_content() );
    

    This allows you to update the gallery whenever you want with whatever you want.

    EDIT:

    To simply display all images:

    $gallery = wp_load_gallery($YOUR_POST_ID);
    foreach($gallery as $image) {
      echo wp_get_attachment_image($image->ID);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I create a page that will upload an image. When i Click upload there's
Trying to create a page that allows users to add edit and view a
I create a page and some parts of it are layout files that are
I want to create a page with will be filled with dynamic info using
I'm am using ASP.NET MVC to create a page that posts to the Paypal
I have a nav button that loads a new page (create.html.erb) through Lightbox 2.
I want to create a page to add, edit and delete a collection of
how do I create a wiki page and add a title, as well as
http://lakers.sonikastudios.com/gallery/sample-gallery-post-1/ That post has several pages using the quicktag of Wordpress. This post is
I try to create image gallery where gallery will have long description like shown

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.