如何在 WordPress 中仅显示帖子的缩略图和标题?

发布于 2025-01-02 14:53:16 字数 212 浏览 1 评论 0原文

如何在 WordPress 中仅显示帖子的缩略图和标题,如下所示: http://themes.premiumpixels .com/?theme=artiste

PS我不是在做任何广告,我只是发布了一个问题,因为我不知道如何做这样的事情。

How can I display only the thumbnail and title of a post in WordPress like here: http://themes.premiumpixels.com/?theme=artiste

P.S. I'm not advertising anything, I just posted a question because I have no idea how to do something like that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光暖心i 2025-01-09 14:53:16

// 从循环中删除 the_content() 或 the_excerpt() 调用

<?php if (have_posts()) : ?>
               <?php while (have_posts()) : the_post(); ?>    
               <!-- do stuff ... -->
               if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail  assigned to it.
                  the_post_thumbnail();
               }
                post_title();// to display the post title
               <?php endwhile; ?>
<?php endif; ?>

// From your loop just remove the_content() or the_excerpt() call

<?php if (have_posts()) : ?>
               <?php while (have_posts()) : the_post(); ?>    
               <!-- do stuff ... -->
               if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail  assigned to it.
                  the_post_thumbnail();
               }
                post_title();// to display the post title
               <?php endwhile; ?>
<?php endif; ?>
你是年少的欢喜 2025-01-09 14:53:16

您需要对图像执行此操作:

http ://www.wpbeginner.com/wp-themes/how-to-add-post-thumbnails-in-wordpress/

您需要对小文本执行此操作:

在 function.php 中添加以下内容:

  add_post_type_support( 'page', 'excerpt' );

然后将其添加到模板中的 post_thumbnail 下方,如链接所示:

    <?php  the_exceprt(); ?>

You need to do this for the image:

http://www.wpbeginner.com/wp-themes/how-to-add-post-thumbnails-in-wordpress/

And you need to do this for the little text:

Add this in function.php:

  add_post_type_support( 'page', 'excerpt' );

then add this below your post_thumbnail in your template as the link demonstrate you:

    <?php  the_exceprt(); ?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文