• Hello,

    I have made a custom post type called Slideshows where I’m storing images for slideshows (one post for each slideshow). And I have a function that gets all image URLs from a specific post using the post ID, but I can’t get this to work with custom posts since they don’t have proper IDs…? Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Custom posts don’t have proper ID’s? They have exactly the same properties as a normal post, with the exception of the post_type field.

    What $args are you using when you try to get the attachemnt URLs? You may need to specify 'post_type' => 'slide_show_type' (where ‘slide_show_type’ is the slug of your custom post type), becuase by default custom post types will be ignored.

    Thread Starter Orabidoo

    (@orabidoo)

    Yes, I thought so. But I can’t see any ID numbers, however I set the permalinks. For regular posts and pages, yes, but custom posts still have URLs like post-type/post-name.

    This is how I pull images from any post or page. Right now I have a ‘hidden’ page tree where I put the slideshow images, but I’d rather use custom posts.

    function get_slide_images($post, $size = 'full', $limit = '0', $offset = '0') {
    
    	$images = get_children( array('post_parent' => $post, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
    Thread Starter Orabidoo

    (@orabidoo)

    Hasn’t anybody else ever done this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Get attachments from a specific custom post?’ is closed to new replies.