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 回答