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 “Remember Me” in custom login
- Using wp_send_json to return HTML
- WordPress Infinite Scroll without using any plugin
- Add post class to the TinyMCE iframe?
- Admin Bar (Toolbar) not showing on custom PHP file that loads WordPress
- How to add query vars with paginated URLs?
- How to change “Shipping Calculator “field label on Cart Page – woocommerce? [closed]
- How to Join two tables from separate databases within WordPress
- How to find objects by terms
- Bypass .htaccess when using download_url
- Anyone can register via backend
- How to get to a specific position in wp_query?
- Preferred Method of debugging a wordpress SQL calls?
- WordPress does not load page.php, return 404.php
- How to use my style.css file outside of wordpress subdomain?
- How do I start using an external API and PHP for a WordPress.org page?
- Unread Repeater field IMG alt not working
- How to add an arrow to menu items has submenus
- I want to load in a new class but only if the current page is single-movies.php
- wp query foreach deleting record returning only first or last item
- Customizer: Category Select Sanitize
- action theme mailchimp subscriber fields
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Skt full width basic slideshow problem
- RTL Stylesheet Confusion with WordPress
- Non-Closing PHP Query in WordPress Loop
- How to determine from a different folder (outside wordpress) if a visitor is logged into WordPress
- Is a series of update_option calls safe, performance wise?
- How to call multiple functions from multiple files into a WordPress page template [closed]
- Display Yoast meta-description `wpseo_desc` within loop of categories and fail silently if no data is set [closed]
- Does get_post function counts as view?
- Get ACF options field in PHP acting as CSS
- Permalinks are not working in WordPress in digitalocean
- Bootstrap Carousel HTML structure and funny output [closed]
- add category to posts with tag wordpress
- Missing a text-domain esc_attr_e
- Get all posts from categories
- How to add post classes?
- How to Generate a list of Most Commented post?
- Updating From Mobile App – Exposing Site to Hacking
- Extract and display user infromation on an automatically created page
- Using multiple variables to assign categories to an array
- Show Custom Menu Name in WordPress 3
- Execute PHP code only with specific user role
- Repeat a function with 24hrs gap for n number of days
- Add a custom WooCommerce settings tab with sections
- How to serve WordPress folder over subdomain?
- How to call my PHP function with AJAX ? wp_query
- Show sidebar only to author of post
- No more get_option(‘date_time’) in WordPress 5.5?
- How to update post content of all posts with tag?
- Make WooCommerce product categories only show images on homepage
- How to Change Site Elements based on referring URL
- WP post meta – for loop inside for loop
- Prepared DB Query from _POST array
- WordPress using get_term to retreive slug not working as expected
- auto metakey value on post tile
- Static home page ignored
- How to pass parameter that ends up being part of a class name with wordpress shortcode
- calling a function from a class in your template
- Custom single.php files for different post formats
- Troubleshooting “loopback requests that take too long”
- AJAX & PHP | Call a specific PHP function from a PHP file via AJAX?
- If I define a variable in header.php, how do I make it available to templates?
- Order woo products, but first products must be with acf fields
- Remove /category/ from category (archive) page URLs (without using a plugin)
- JSON Object Value Show Undefine