问:这是从Bootstrap到Wordpress课程的视频。视频为“ Finishing Up Our Bootstrap Slideshow Carousel”。不管我盯着我的代码多少次,它看起来都和视频中的代码完全一样。我不知道为什么我的替代文字不会显示。这是我的代码:
<?php $ thumbnail_id = get_post_thumbnail_id(); $ thumbnail_url = wp_get_attachment_image_src($ thumbnail_id,'thumbnail-size',true); $ thumbnail_meta = get_post_meta($ thumbnail_id,'_wp_attachment_image_alt',true); ?>
<一个 HREF = “<PHP the_permalink();?>” > < IMG SRC = “<PHP的回声$ thumbnail_url [0];?>” ALT = “<PHP的回声$ thumbnail_meta;?>精选图像” > </ a >
这是整个文件(home.php):
<?php get_header(); ?>
<div class =“ container”> <div class =“ row”> <div class =“ col-md-9”>
< div class = “ page-header” >
< h1 > <?php wp_title(''); ?> </ h1 > </ div > <?php $ args = array( 'post_type'=>'post', 'category_name'=>'featured' ); $ the_query =新的WP_Query($ args); ?> < div id = “ carousel-example-generic” class = “ carousel slide” data-ride = “ carousel” > <!-指示器->
>
<?php if(have_posts()):while($ the_query-> have_posts()):$ the_query-> the_post(); ?> < li data-target = “#carousel-example-generic” data-slide-to = “ <?php echo $ the_query-> current_post;?>” class = “ <?php if($ the_query-> current_post = = 0):;?> active <?php endif;?>“ > </ li > <?php endwhile; 万一; ?> </ ol > <?php rewind_posts(); ?> <!-幻灯片包装器-> < div class = “ carousel-inner” role = “
<?php if(have_posts()):while($ the_query-> have_posts()):$ the_query-> the_post(); ?>
< div class = “ item <?php if($ the_query-> current_post == 0):;?> active <?php endif;?>” > <?php $ thumbnail_id = get_post_thumbnail_id(); $ thumbnail_url = wp_get_attachment_image_src($ thumbnail_id,'thumbnail-size',true); $ thumbnail_meta = get_post_meta($ thumbnail_id,'_wp_attachment_image_alt',true); ?> <一个HREF = “<PHP the_permalink();?>” > < IMG SRC = “<PHP的回声$ thumbnail_url [0];?>
“ <?php echo $ thumbnail_meta;?>特色图片” > </ a >
< div class = “轮播字幕” > <?php the_title(); ?> </ div > </ div > <?php结束;万一; ?> </ div > <!-控件-> <一个类= “ left carousel-control” href = “#carousel-example-generic” role = “ button” data-slide = “ prev” > <
aria-hidden = “ true” > </ span >
< span class = “ sr-only” >上一页</ span > </ a > < a class = “ right carousel-control” href = “#carousel-example-generic “角色= ”按钮“ data-slide = ”下一个“ > < span class = ” glyphicon glyphicon-雪佛龙右“ aria-hidden = ” true“ > </跨度> <跨度
类= “SR-仅” >下一步</跨度>
</一> </ DIV > <?PHP如果(have_posts()):而(have_posts()):the_post(); ?> <文章类= “POST” > < H2 > <一个HREF = “<PHP the_permalink();?>” > <PHP the_title()?; ?> </ a > </ h2 > < p > < em > 通过<?php the_author(); ?> 在<?php echo the_time('l,F jS,Y'); ?>
在<?php the_category(',');中 ?>。
<一个HREF = “<PHP comments_link();?>” > <PHP comments_number()?; ?> </ a > </ em > </ p > <?php the_excerpt(); ?> < hr > </ article > <?php结束;否则:?> < div class = “ page-header” > < h1 >哦,不!</ h1 > </ div > <
该页面没有内容!</ p >
<?php endif; ?> </ div > <?php get_sidebar('blog'); ?>
</ div>
<?php get_footer(); ?>
答: 为图片设置了替代设置吗?我在您的代码中找不到任何错误。