只有在标题中有*时才在wordpress中发布图像

This is what I have now in my page-name.php:

<?php

   $args = array(
     'post_type' => 'attachment',
     'numberposts' => -1,
     'post_status' => null,
     'post_parent' => null, // any parent
     'post_mime_type' => 'image'

);  
 $attachments = get_posts($args);
  if ($attachments) {
     $attachment_meta = wp_get_attachment($attachment->ID);
            foreach ($attachments as $post) {
            if ($attachment_meta['caption'] == 'Ceahlau' ){
            setup_postdata($post);
               echo wp_get_attachment_image( $attachment->ID, 'full' );
               the_attachment_link($post->ID, false);

                            }
                }  
}

?>

And this is what I have in functions.php:

function wp_get_attachment( $attachment_id ) {

    $attachment = get_post( $attachment_id );
    return array(
        'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
        'caption' => $attachment->post_excerpt,
        'description' => $attachment->post_content,
        'href' => get_permalink( $attachment->ID ),
        'src' => $attachment->guid,
        'title' => $attachment->post_title
    );
}



$attachment_meta = wp_get_attachment($attachment->ID);

Can you please tell me what is wrong with my functions? I want to post image only if they have "Ceahlau" in caption.