【问题标题】:wordpress template layout single.phpwordpress 模板布局 single.php
【发布时间】:2017-07-27 01:48:20
【问题描述】:

我需要在我的 wordpress 模板中自定义 single.php 模板。 在我的 single.php 中有这一行

我的新模板需要显示帖子图片、帖子日期、帖子文本。

我该怎么做?

谢谢

【问题讨论】:

标签: wordpress templates


【解决方案1】:

Google 可以很容易地告诉您这是如何完成的,但因为我在这里,所以我会提供帮助。

首先,学习WordPress Loop

打开您的 single.php 模板并粘贴以下内容:

<?php 
    if ( have_posts() ) {
        while ( have_posts() ) {
            the_post(); 

            // Post Image
            the_post_thumbnail();

            // Post Date
            the_date();

            // The Post Content
            the_content();

        } // end while
    } // end if
?>

然后阅读使用的功能:

the_post_thumbnail()

the_date()

the_content()

【讨论】:

  • 谢谢!抱歉,我是 wordpress 的新手,我开始阅读相同的想法。
  • 尝试使用此处的答案删除图像:wordpress.stackexchange.com/a/162165/70417
  • 最后,我的解决方案是使用 wordpress.stackexchange.com/a/162165/70417 从 single.php 中删除图像。如果存在特色图片,我会通过 php 代码显示。谢谢!
猜你喜欢
  • 1970-01-01
  • 2016-09-08
  • 1970-01-01
  • 1970-01-01
  • 2020-04-24
  • 1970-01-01
  • 2015-11-29
  • 2016-09-01
  • 1970-01-01
相关资源
最近更新 更多