You are trying to get the ID via $post->ID
, but that will only return the post ID of the first post. You can use global $post;
before the args array, or much simpler replace $post->ID by the function get_the_ID()
.
$args = array('post_type' => 'attachment', 'numberposts' => 34, 'post_status' => null, 'post_parent' => get_the_ID());
Related Posts:
- Getting paginate_links() ‘end_size’ to display none
- Check if a menu is empty?
- Use wc_enqueue_js only on specific pages – nested add_action
- WordPress theme & site not loading after moving files
- Removing unnecessary wordpress files
- WP_Query use for a filter with multiple Taxonomies and Terms
- WP Plugin + OOP: Adding Menu Page doesn’t create required effect
- Can I run custom php on specific pages in wordpress?
- Use is_product_category() properly
- list posts and wrap them alphabetically A-Z
- Style wp_page_menu() items
- Link to the parent post in attachment page
- Convert all images to PNG on file upload
- White Screen of Death – wp-admin
- How to update WP about renamed files
- How to sanitize my cookie name
- WordPress 5 WP REST routes – No errors
- Custom page archive query by url var calling page twice on one of my custom queries?
- Any possible way to make $wpdb->get_results() return anything else than array?
- Add prefix to link url
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Change list item content in menu navigation to add a child element with specific class
- Selectbox in admin panel function linking to CSS
- Is it better to create a function or a variable for current_theme_supports?
- wordpress allow user to edit user profile with custom fields
- Making BuddyPress Activity Stream (Post Type) Featured Images Clickable [closed]
- Which field should I edit to make the checkbox marked by default?
- Add filter when image is uploaded?
- How can I save unique user data on my site? [closed]
- Add New User, extra fields which are required?
- Repeating admin-ajax.php not found error in admin
- Remove a div from RSS feed
- Keyword checking in Gravity Forms
- how to refresh div on template part?
- Child page menu in sidebar
- Any way to add -1 suffix to the end of every new post?
- Are all hooks/functions tied to Kses meant for sanitization?
- Using custom tables for old posts
- Change page title from page using php via php executed from page/post itself
- Download images from media library to computer in BULK?
- How to array only one key from another array
- Detecting if parent page has gallery
- WordPress and MySQL: trying to print data using PHP from user_meta custom field data
- Removing WordPress Footer -without access to PHP code?
- Convert a string into a decimal number for use in query
- How to get specific attribute from DB
- customize woocommerce templates and display store on home
- Delete or edit postmeta with specific meta_key?
- Post repeated when opening in overlay, how do I solve this? [closed]
- Woocommerce: remove total sum from new order’s email [closed]
- Concatenate Custom Field Value & HTML Value
- How do I properly code my footer? See example
- how to hide or disable some part in specify page
- Use of IF statement in Header file
- Include a file that has a function in it
- Kohana Frontend, WordPress Backend
- making my own “related pages” / “pages you might like” section
- apply_filters with several different values?
- How do you create a custom category widget that you can style?
- Add Custom Category Description When Empty
- How to preload header logo image in WordPress? like what’s the code and where do I put it?
- echo cutom css code to WordPress page template file ? is this safe?
- Contain multiple page templates in one PHP custom template file in WordPress?
- Custom plugin: how do I call a PHP file if settings option is set to true?
- PHP `iconv` not working inside a WordPress site
- How to edit button permalink inside function.php using a child theme?
- Replacing entire tag with shortcode – JavaScript [duplicate]
- How do I visualize the author’s post from the front end?
- How to add a full working piece of website already coded, to a large scale Website design project?
- Elementor to custom wordpress page
- custom post type not showed with bootstrap 4 modal and template part
- Query to show average # of months all accounts with specific role have been active
- Send email to users when they get new followers
- Conditionally change WordPress core language
- Remove item from post_meta array via AJAX
- Shortcode just with a php code
- WooCommerce Custom Tab with ACF Repeater Field
- My WP Website Shows HTTP ERROR 500
- add menu page in loop menu order
- CSS loading as empty file in Custom Theme
- Calling WordPress hook from within a class: call to undefined function error
- wp_send_json erase last value
- PHP array to jQuery array ” Uncaught SyntaxError: Unexpected token < "
- Dynamically Create Posts Via XML File
- pages disable after wordpress update
- How to only fetch certain Tag ID’s
- AdWords API with WP
- Add title and caption to thumbnail image on mouseover
- How to set a cookie based on a page Get variable?
- Editing the contents of just one div on a page from wordpress
- Postmeta not saving
- Missing items on page
- Display latest 5 posts on homepage
- WordPress blog set up
- Cannot get custom javascript to execute on page
- Display Current Time using shortcode
- WP and Laravel integration (Updated) [closed]
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- Custom Post Type doesn’t have template content when creating programmatically in PHP but does when created in WP Admin
- How can add alt tag in following code. Image are showing dynamic in wordpress