【问题标题】:call wordpress post content on another external php page在另一个外部 php 页面上调用 wordpress 发布内容
【发布时间】:2015-02-24 16:12:48
【问题描述】:

公开 |-- index.php(外部) |-- post-viewer.php(外部) |-- /WP(wp安装)

我正在尝试从外部页面调用 wordpress 安装的帖子。 我设法从索引页面显示帖子标题、摘录、缩略图和帖子内容(通过以下教程:http://codex.wordpress.org/Integrating_WordPress_with_Your_Website)。

当我点击 index.php 上的帖子标题时,我的浏览器被重定向到 Wordpress 网站(我想对公众隐藏)。

如何让帖子内容出现在 post-viewer.php 上?

谢谢

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    加载 WordPress 核心功能并通过 get_post 选项加载

    <?php
    
       require_once("wp-load.php");
    
       $post = get_post( 12 ); // your post id
    
       echo $post->post_content;
    
    ?>
    

    【讨论】:

    • 我的意思是当你点击页面A上的链接时如何在页面B上显示内容。
    猜你喜欢
    • 1970-01-01
    • 2018-04-25
    • 2016-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-11
    • 2011-06-01
    相关资源
    最近更新 更多