Php 仅当标题中有*时才在WorpAddress中发布图像
这就是我现在在Php 仅当标题中有*时才在WorpAddress中发布图像,php,wordpress,Php,Wordpress,这就是我现在在页面名.php中的内容: <?php $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null, // any parent 'post_mime_type' => 'image' ); $attachments = ge
页面名.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);
}
}
}
?>
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);
你能告诉我我的功能有什么问题吗?只有当他们的标题中有“Ceahlau”
时,我才想发布图片。我们无法告诉您出了什么问题。你为什么不告诉我们问题出在哪里?“这是我的代码,有什么问题?”这不是一个好问题。请看,我想要一个函数,发布标题中有“Ceahlau”的图像。我怎样才能请求您帮助我完成该功能?:)@本姆