【发布时间】:2017-11-01 03:25:08
【问题描述】:
我已经使用 WP 模板 http://wpshower.com/themes/expositio/ 构建了一个简单的网站
没关系,但它不显示替代文本,我无法弄清楚 php 设置。这是图片的代码:
* The template for displaying image attachments
// Retrieve attachment metadata.
$metadata = wp_get_attachment_metadata();
get_header();
?>
<section id="primary" class="content-area image-attachment">
<div id="content" class="site-content" role="main">
<header class="entry-header">
<?php the_title('<h1 class="entry-title">', '</h1>'); ?>
<div class="entry-meta">
<div class="full-size-link">
<a href="<?php echo wp_get_attachment_url(); ?>"><?php echo $metadata['width']; ?> × <?php echo $metadata['height']; ?></a>
</div>
<div class="parent-post-link">
<a href="<?php echo get_permalink($post->post_parent); ?>" rel="gallery"><?php echo get_the_title($post->post_parent); ?></a>
</div>
</div>
</header><!--
--><article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content">
<div class="entry-attachment">
<div class="attachment">
<?php expositio_the_attached_image(); ?>
</div><!-- .attachment -->
<?php if (has_excerpt()) : ?>
<div class="entry-caption">
<?php the_excerpt(); ?>
</div><!-- .entry-caption -->
<?php endif; ?>
</div><!-- .entry-attachment -->
<?php
the_content();
wp_link_pages(array(
'before' => '<div class="page-links"><span class="page-links-title">'.__('Pages:', 'expositio').'</span>',
'after' => '</div>',
'link_before' => '<span>',
'link_after' => '</span>',
));
?>
【问题讨论】:
-
你在哪里打印 alt?
-
你必须找到这个函数
expositio_the_attached_image();的定义并修改它(如果你自己不能做到,可能会告诉我们它的代码和文件名) -
找到它:function expositio_the_attached_image() { $post = get_post(); */ $attachment_size = apply_filters('expositio_attachment_size', array(810, 810)); $next_attachment_url = wp_get_attachment_url(); $attachment_ids = get_posts(array( 'post_parent' => $post->post_parent, 'fields' => 'ids', 'numberposts' => -1, 'post_status' => 'inherit', 'post_type' => ' attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID', ));
-
是您要显示的缩略图/特色图片吗?`