There is no way to limit the gallery query in the shortcode_gallery function. However, you can get the child attachments of a post using the following.
$attachments = get_children( array('post_parent' => $post->id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'numberposts' => 5) );
You will need to iterate through the attachments and build out your gallery HTML.
Related Posts:
- How to manually fix the WordPress gallery code using PHP in functions.php?
- How to draw media details for Isotope gallery using Photoswipe
- PHP/Manual use of images? – 2 Questions
- Adding Image Count to Multigallery
- Get a Page’s attachments in Gallery order
- Using an Image Slider twice on the same page
- How to return output of the new wp gallery block for automatically Link images To Media file
- Add a class to the anchor tag on HTML5 gallery
- Showing a different gallery in a seperate post
- Create own WordPress shortcode gallery
- How to get next image with this code from same post?
- Upload multiple images to a Woocomerce product
- Way to add captions to gallery images by code
- Custom gallery in wp3.5
- WordPress automatically adds links to uploaded images
- Get title attribute from galleries
- Detecting if parent page has gallery
- Timthumb.php image gallery not working on Multisite WordPress
- Change default gallery images – Currently they are displaying full size imagese
- How do I increase the upload size only when editing special pages?
- Auto create Nextgen Gallery on post creation [closed]
- Delete images from media library when user deletes an image from ACF Gallery
- Create shortcode for metabox gallery
- Display metabox galleries on specific page template in admin editor
- ACF Gallery field images donwload
- add custom link to gallery images
- Javascript Tab Gallery with Advanced Custom Fields
- How to generate customized filtered output for the gallery
- offset and max_num_pages in pagination gallery
- Using catch_that_image() for galleries?
- Creating image gallery in wordpress
- Dynamic Gallery
- Gallery requires a featured image but does not show it in posts/pages
- Adding a css class to the gallery
- If ‘editor’ is empty, then
- Different Subdomain changes page content
- Theme not calling Jquery properly
- customize wordpress database error page
- Removing the comment function within wordpress
- Creating Database Table vs. Adding MetaData to Post & User
- Post’s ID pattern?
- Countdown to date function?
- Include text in echoed hyperlink
- How to put a form with php code into a variable or shortcode?
- Utilize Function in Child Theme / Template File
- Add class to DIV depending on page loaded
- Need oop for wordpress theme? [duplicate]
- Display Youtube Time Automate from Key
- Content filter won’t work
- How to retrive the text : No movie by this actor
- Make a database query using WordPress
- Is the 404 page automatically displayed if a loop returns nothing?
- update_post_meta only updating on last loop of foreach
- How to have different header.php based on the user logged in?
- How do I remove a category from a wordpress loop>
- How can i count the post added in relationship field, theme display
- Link blogname and blogdescription to the Options Framework
- Liking a facebook page from wordpress website?
- Isotope Drop Down Categories Filter Function
- First Byte Time (back-end processing)
- How do I define a lookup table that will work across all PHP elements of the template?
- How to keep track of when a vote is cast?
- trouble with page_id & highlighting current page
- Convert the_permalink() function output into string
- Making my first wordpress template
- How to use array in function to get only value I want
- Apply class to every third list item? [duplicate]
- Only show image from custom field when present
- Cinema site, retrive the movies that actor play in
- How to include custom code on a page that’s set to act as homepage?
- retain querystring values when savincustom options in admin
- PHP if statement works in template files, but not header
- How Can I Edit the Registration Code?
- Error while setting role
- Editing a PHP file to include a small text piece on every page
- Get categories names as an array to use it in theme settings
- Should i use the wordpress Options table or to create database table..?
- variable value disappears in a second loop
- Force Users To Relogin
- unknown issue in ‘header.php’ preventing theme from displaying fully
- Hide a div to subscribers(user role) in one page (is_page)
- Security updates to 3.3.2
- Where is this function’s callback getting its arguments from?
- How can I use a sliced image As banner? [closed]
- persist a variable set in header.php all the way down to footer.php
- Echo title attribute php
- Can a page contain php code?
- Last class on last headline?
- Unable to Find Space in Custom Function
- Is it possible to display a DIV to not logged in users and then change it for users who are logged in?
- Strip Paragraph Tag
- Unable to process php via shortcode
- working with term_relationships table
- Creating a blog on my companies new website using WordPress but I have sidebar issues
- Creating a mobile site by adding a new class to the body tag from functions.php
- WordPress plug-in for dynamic download link?
- Using WP functions such as the_title() in an included php file
- GET problem in WordPress
- Almost Done… Post Format Code
- wordpress admin plugin menu custom css