YouTubeの動画が埋め込まれている投稿がいくつかあります。投稿のフルバージョンにのみ動画を表示したい。投稿を一覧表示するカテゴリページで、動画を表示したくありません。
ここにサイトがあります:http://tsa-watch.com/
投稿の完全版:
カテゴリページにリストされている場合にのみ、投稿から最初の画像を削除するためにfunctions.phpで使用するコードを次に示します。
function remove_first_image ($content) {
if (is_category()) {
$content = preg_replace("/<img[^>]+\>/i", "", $content, 1);
$content = preg_replace("/<object[^>]+>/i", "", $content, 1);
} return $content;
}
add_filter('the_content', 'remove_first_image');
また、index.phpファイルとcategory.phpファイルで使用しているループは次のとおりです。
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="votes" style="min-width:60px"><strong>VOTES:</strong><?php wdpv_vote(false); ?></div>
<div class="alignleft" style="max-width:590px">
<h2 id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
<?php the_title(); ?></a></h2>
<div class="byline"><?php the_time('F jS, Y') ?> by <?php the_author() ?> in <?php the_category(', ') ?> <strong>:</strong> <?php comments_number( 'No Comments', '1 Comment', '% Comments' ); ?></div>
<div class="excerpt">
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail(array(115,115));
}
?>
<?php the_content('Read more »'); ?>
</div>
<?php endwhile; ?>
<?php else : ?>
<h1>Not Found</h1>
<p><?php _e("Sorry, but you are looking for something that isn't here."); ?></p>
<?php endif; ?>
どんな助けもいただければ幸いです...