有没有办法告诉wordpress内容页面在有特色图片时在内容周围显示一个div,如果没有,则删除那里的div?我编写 Html 和 css 代码,但 php 对我来说很模糊。有怜悯 :) 如果它不存在,我目前有它放置一个虚拟缩略图代替特色图像。见下文。谢谢!!
<header class="entry-header">
<?php if ( is_search() || is_archive () || is_category () || is_tag () || is_home() ) : // Only display Excerpts for Search ?>
<?php if ( is_single() ) : ?>
<h1 class="entry-title post-title"><?php the_title(); ?></h1>
<?php else : ?>
<?php endif; // is_single() ?>
<?php if ( comments_open() ) : ?>
<!--<div class="comments-link">
<?php // comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
</div>--><!-- .comments-link -->
<?php endif; // comments_open() ?>
<footer class="entry-meta post-content">
<?php
if ( has_post_thumbnail() ) {
echo '<figure class="cat-thumb">';
the_post_thumbnail('category-thumb');
echo '</figure>';
}
else {
echo '
<figure class="placeholder-thumb">
<p><h1 class="entry-title"><?php echo single_post_title() ?></h1></p>
</figure>
';
}
?>
<div id="blogPostContent">
<p class="post-title"><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a></p>
<div class="entry-summary">
<div class="postByLine">
<?php
$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() )
);
$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ),
get_the_author()
);
echo ' Published on ' . $date . ' | By ' . $author . ' | ';
if ( comments_open() ) : ?>
<?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
<?php endif; // comments_open()
?>
</div>
<?php the_excerpt(); ?><span class="read_more"><a href="<?php the_permalink(); ?>">Read More</a></span>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content">
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
<?php endif; ?>
</div>
</footer>
</header><!-- .entry-header -->