1

YouTubeの動画が埋め込まれている投稿がいくつかあります。投稿のフルバージョンにのみ動画を表示したい。投稿を一覧表示するカテゴリページで、動画を表示したくありません。

ここにサイトがあります:http://tsa-watch.com/

投稿の完全版:

http://tsa-watch.com/2013/03/25/tsa-makes-double-amputee-marine-remove-prosthetic-legs-during-screening/

カテゴリページにリストされている場合にのみ、投稿から最初の画像を削除するために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 &raquo;'); ?>
        </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; ?>

どんな助けもいただければ幸いです...

4

1 に答える 1

4

これは私が信じているWordPressサイトですか?

その場合は、カテゴリページに投稿のプレビューを表示するテーマテンプレートファイルの編集を確認し、画像/動画が表示されているセクションを投稿から削除する必要があります。

残念ながら、使用しているテーマやファイル名がわからないため、わかりにくいですが、homeまたはcategoriesという単語が含まれているページテンプレートを探すか、アクティブ化されたテーマフォルダ内からcategory.phpを開きます。これに関連する何かを見つけることができるかどうかを確認し、コメントアウトして修正されるかどうかを確認するように依頼します。

また、カスタム関数内に次を追加してみてください。

$content = preg_replace("/<embed[^>]+>/i", "", $content, 1);
于 2013-03-26T02:25:27.627 に答える