How to display images that was uploaded in the media gallery and not by the current post?
Changing ‘post_parent’ => $post->ID to ‘post_parent’ => null will fetch all images.
Changing ‘post_parent’ => $post->ID to ‘post_parent’ => null will fetch all images.
Take a look at gallery shortcode documentation (Codex) id specify the post ID. The gallery will display images which are attached to that post. The default behavior, if no ID is specified, is to display images attached to the current post. For example, to display images attached to post 123: So yes, you should put … Read more
A gallery is at heart just the set of attached posts, so… $post_id = 1; // set to your desired parent post $attachments = new WP_Query( array( ‘post_parent’ => $post_id, // post to which the gallery is attached ‘post_status’ => ‘inherit’, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, // ‘order’ => $order, // ‘orderby’ => $orderby … Read more
Okay, looks like it was my fault, I’ve been playing with shortcodes long time ago and I found out something like this within functions.php: require_once (‘gallery-shortcode.php’); Apparently it replaced the original shortcode and when it happens everything gallery-related breaks / returns nothing 🙂
Use posts_per_page instead of numberposts So the $args for the get_posts would be like below and also the param for post_status is wrong. Check the codex for the details here Also when when you are fetching one attachment it is useless to set a counter for it. You can use the modified function function get_random_gallery_images(){ … Read more
How can I make gallery slideshow width fit to picture width?
This method enables you to display the native WordPress gallery using the gallery shortcode in a custom function How to call a plugin function in footer.php You can use any WordPress or theme specific hook.
Gallery can include either: specific images, in which case their IDs are explicitly listed in shortcode all images attached to the post, in which case shortcode doesn’t specify that (as in your example) So your description is a little contradictory – if images weren’t attached to the post, then that example wouldn’t have worked in … Read more
There are a few issues here, but I’m not sure that any one directly is your problem. First, you need to be more specific in your pre_get_posts callback conditional, to ensure you’re targeting only the main query. Second, you need to clarify the post type you’re intending to show. Third – and the one that … Read more
As an alternative to removing the image sizes (which digging a little deeper looks very complicated), why not change the size of the images in your gallery? If you use a larger image they will “fill the space” at larger screens and then shrink down for smaller screens. The Gallery shortcode has a size parameter … Read more