Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to select some attachements based on an attachement caption. I need to do this for a seperate download page. On the download page i want to display all attachment which caption equals "downloads". So this way i can be selective of post attachments which can and can't be downloaded

At the moment i have this code to select all the attached pdf's as downloable files, but i like to select some attached images and deselect some pdf's.

    $args = array('post_parent' => $atts['product_id'],
    'post_status' => 'inherit', 'post_type' => 'attachment',
    'post_mime_type' => 'application/pdf', 'order' => $order, 'orderby' => $orderby);
$attachments = get_posts($args);
    //print_r($attachments);
        $i = 1;
        foreach ($attachments as $attachment) {
...
$attachment->guid

i am also able to select images based on there given thumbnail name with

wp_get_attachment_image($attachment->ID,'product-slider-thumbnail')

but how to select based on caption??

regards

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Ok found a solution by using this in the loop

if ($attachment->post_excerpt == 'download') {

Where i have put "download" in the caption textfield.

hmmm, what if i want to select an image with 2 or more different captions?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.