【问题标题】:Wordpress page content variableWordpress 页面内容变量
【发布时间】:2016-11-12 18:25:31
【问题描述】:

我是 wordpress 编码的新手,但熟悉标准 HTML/CSS。在各种在线教程的帮助下,我终于将一个简单的 HTML/CSS 网站转换为 wordpress,但我错过了一些基础知识。

在这种情况下,我只是想设置我的模板以使用 page.php 文件,以便我可以通过 wordpress 管理控制台创建页面。我已经想出了如何让 head.php、footer.php 和 functions.php 为样式和 js 文件工作,但现在我正在努力解决我需要放置什么变量以便我进入页面的标题和内容通过 wordpress 管理员出现。

我试过了

1) 在我的 page.php 文件中使用 div id=content ——这不起作用 2) 我已经尝试添加到我的 page.php 文件中——那没有用

我似乎无法弄清楚。任何帮助将不胜感激。我是这里的初学者,非常感谢任何帮助。谢谢!

【问题讨论】:

    标签: wordpress


    【解决方案1】:

    这是 Wordpress 中 page.php 的一个非常基本的模板。

    <?php get_header(); ?>
    
        <div>
                <?php
                if( have_posts() ) :
                    while ( have_posts() ) : the_post();
    
                       the_title(); // Outputs the title of the page
                       the_content(); // Outputs the content of the page
    
    
                    endwhile; // End of the loop. 
                endif;
                ?>
    
        </div>
    
    <?php get_footer(); ?>
    

    另外,如果您想先将标题和内容存储在 php 变量中,您可以调用 get_the_title()get_the_content()

    如果您遇到问题,请告诉我。

    【讨论】:

      猜你喜欢
      • 2014-01-18
      • 2017-08-06
      • 1970-01-01
      • 2011-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多