Tag Info

Hot answers tagged


I think the reason for this is the get_page_by_path() check inside the WP_Query, because it's checking for both page and attachment slugs, in this case. So if we have both an attachment and a post with the someslug postname and visit: example.tdl/someslug then get_page_by_path() will generate the following query: SELECT ID, post_name, post_parent, ...


I tried to write some snippet with the help of WordPress codex. Please check below and update it further as per your needs. I hope this helps: global $post; $args = array( 'numberposts' => 1, 'order' => 'ASC', 'post_mime_type' => 'image', 'post_parent' => $post->ID, 'post_status' => null, 'post_type' => ...

Only top voted, non community-wiki answers of a minimum length are eligible