Php 对于WordPress图像,Alt标记为空
我有一个问题,就是我无法准确地找出缺少什么来声明image alt标记。网站页面发布在这里- 我也张贴了模板的代码。如果你能帮我解决这个问题,那就太好了。请在此处检查代码:Php 对于WordPress图像,Alt标记为空,php,wordpress,image,alt,Php,Wordpress,Image,Alt,我有一个问题,就是我无法准确地找出缺少什么来声明image alt标记。网站页面发布在这里- 我也张贴了模板的代码。如果你能帮我解决这个问题,那就太好了。请在此处检查代码: <?php /** * Template Name: Blog * * @package WordPress * @subpackage Twenty_Fourteen * @since Twenty Fourteen 1.0 */ get_header(); ?> <?php $page_i
<?php
/**
* Template Name: Blog
*
* @package WordPress
* @subpackage Twenty_Fourteen
* @since Twenty Fourteen 1.0
*/
get_header();
?>
<?php
$page_id = $wp_query->post->ID;
?>
<div id="bd">
<div class="blog-sec">
<div class="container blog-main">
<h2>Blog</h2>
<div class="blog_left">
<?php
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts' => 1
);
$my_query = null;
$my_query = new WP_Query($args);
if ($my_query->have_posts()) {
while ($my_query->have_posts()):
$my_query->the_post();
$feat_image = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
?>
<div class="blog_blocks">
<div class="blog_thumb"><a href="<?php
echo get_permalink();
?>" ><img src="<?php
echo $feat_image;
?>" alt=""></a></div>
<div class="blog_content">
<h5><a href="<?php
echo get_permalink();
?>" ><?php
the_title();
?></a></h5>
<?php
$content = substr(get_the_content(), 0, 115) . "...";
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
?>
<a href="<?php
echo get_permalink();
?>" class="readmore">
<?php
if (get_bloginfo('language') === "en-US") {
echo get_option('of_blogtext_eng');
} else {
echo get_option('of_blogtext_french');
}
?>
</a>
</div>
</div>
<?php
endwhile;
}
?>
</div>
<div class="blog_right">
<?php
if (is_active_sidebar('blog')):
?>
<?php
dynamic_sidebar('blog');
?>
<?php
endif;
?>
</div>
<div class="clear"></div>
</div>
</div>
</div>
<?php
get_footer();
?>
博客
请告诉我需要将哪些元素添加到数组中,或者声明Image变量,并在它们之间为ALT标记编写echo语句。那里有一整段代码实际上并不需要:
$feat\u image=wp\u get\u attachment\u url(get\u post\u缩略图\u id($post->id))代码>
“alt=”“>
删除$feat_image
行,并将第2位替换为
使用the_post_thumbnail()
函数将输出必要的HTML并自动填充alt文本,当然前提是文本已输入媒体库中的图像帖子中
希望这能有所帮助,我不明白。你是在问我们你应该如何编写alt=”“
?
<img src="<?php
echo $feat_image;
?>" alt="">