You aren’t getting an image because you are calling the image field outside the query loop.
<?php $args = array(
'post_type' => 'slide',
'posts_per_page' => 1,
'orderby' => rand
);
// url = $image[0];
// width = $image[1];
// height = $image[2];
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
$attachment_id = get_field('slide_photo');
$size = "medium"; // (thumbnail, medium, large, full or custom size)
$image = wp_get_attachment_image_src( $attachment_id, $size );
echo '<img src="';
echo $image[0];
echo '" />';
the_title();
the_field('slide_credit');
endwhile; ?>
Related Posts:
- How to extract images of post and pages excluding header and logo image in wordpress?
- how do i remove posts from a WP_Query so the pagination is right?
- Insert content of a post into another
- Redirect to another page using contact form 7? [closed]
- How to get a list of bundled products using wp_query in woocommerce
- Loop returns the current page’s permalink and guid instead of the post in the loop
- Multiple images per post – Show random image elsewhere
- Display products from specific category in shop page
- Resizing all images
- Automatically Import Image into Posts from URLs on the Web?
- How can I attach images to a post from the media library?
- Rename existing old uploaded images containing accented French characters (not during upload)
- Thumbnail with different sizes
- How to count number of records found in a database table?
- Disabling post images for not logged in users
- How to upload thousands of images?
- Is it possible to filter the wp_footer() scripts, read the content, and insert them inline?
- Advanced Custom Fields query
- There’s some way to add a wrapper around posted images?
- How to get CMB2 to show a single image at a specific size
- Can I run multiple queries with $wpdb->prepare?
- Getting media library popup in custom plugin admin page
- bulk change of image setting “link to” to “link to: image url “
- WP_Query ordering numbers as letters
- WooCommerce shop page orderby [closed]
- Inserting HTML tag with ACF into shortcode
- Images not showing after changing wp-content folder name
- How do I “get the next 10 posts after post_id == x”?
- How to Delete all Unused photos Function
- DROP TABLE with uninstall hook not working
- Load external images via proxy
- Can we have an ‘Update metadata’ button in Image Gallery for all image instances?
- Add ALT attribute to Pin It Button image to pass HTML5 validation
- Adding (image) caching to my Tumblr widget
- Get User_id outside wordpress,
- Import Instagram post to WordPress blog post
- Where to find the code used to render a page that has a shortcode and a template defined?
- WordPress Apply filter in plugin causes 500 internal error
- Meta query for comparing two dates
- In Woocommerce theme need to add custom external link [closed]
- Photo Gallery Plugin and Touch Devices
- Skewed / slanted button within elementor [closed]
- How can I automatically download all images from all imported posts, place them on my new host, and replace all the links
- Plugin for an interactive image? [closed]
- How to fix broken media library?
- Add “Featured Image” box in my plugin post page
- Trying to add_action in a loop
- Add user meta after a user has registered and logged In [closed]
- Blurry images when loading the page first time
- Image Galleries for website migrated from .com to .org
- How to get CPT category checkbox list and show post of selected(multiply) checkboxes via ajax?
- JSON API Plugin not showing Attachments id reused
- Output after specific post in the loop
- Delete data from custom table when deleting a post
- Plugin is creating posts twice
- Some images on WordPress site are suddenly gone
- Regenerate Thumbnails Plugin successfully updated my thumbnails but image src won’t change to new image size?
- Pagination not working
- Replace image urls(absolute instead of relative) by using filter in single page
- Simple sildeshow/image-upload plugin?
- Searching a tab/space delimited text file based upon form criteria and returning a ‘record’ into a word press results page
- How to search post titles with whole words only, but not the exact word only?
- how to remove share button from image overlay
- How to hide featured images of all posts falling under the same category in wordpress?
- Upload Image with a file URL and show dynamically on Frontend
- Use get_pages() before another plugin modifies it
- How to Join wp_posts & wp_postmeta table using custom query
- insert og image link in wordpress post
- How to Upload images to a custom folder in upload folder using media uploader
- Product Page loads terribly slow when product gallery images are added
- WordPress how do I change images used in plugins?
- Only return taxonomies that are linked to a category & product
- How to add specific posts to specific pages in WordPress?
- Help finding a plugin – masonry type post grid
- How to wrap image tag into div for post only?
- How to use information from the database in the front-end?
- User Following System
- ACF Query result in a new td (echo)
- Multiple Meta key in search
- History of page, interval of years
- Theme Load Error
- Second foreach loop breaking (Posts2Posts)
- Server Path Information
- Ger posts from similar tags and categories
- wp_query for more fields plugin
- Get gallery and product gallery images full size
- ‘all’ hook and add_action issue (class based plugin)
- Display alt text as tool tip on page
- wpdb get_var is not returning any result (verified mysql query returns only one value)
- Adding Relevant Post Images
- single.php fires more than once after clicking on any post to view with different post id each time
- Include subtitle display to slideshow
- How can I save a setting field with multiple checkbox options generated by a foreach loop on a custom wordpress admin page?
- Image Layout in Posts
- how to embed a crop feature for cropping images uploaded by the user
- Achieve the following layout
- Page with redirect
- Order custom post type by posts with most likes first
- How To Convert External Image URLs To Own Website’s Uploaded Images Automatically?
- Accessing Correct Database to Create REST API Endpoint