[英]WP in subdirectory: how to show items on non-wp in root
Wordpress 安裝在子目錄 «/blog» 中,可以在那里訪問。 我試圖找出如何將最后一個博客項目作為非 wp 根目錄 «index.php» 中的主要文章。
我所能找到的只是關於子目錄中的 WP,如果它在根目錄中就起作用,但這不是我想要的。 博客必須留在子目錄中,因為站點的其余部分是非 WP 的。 我知道這是可能的; 幾年前我讀過它,但我再也找不到那個來源了。
在根索引中添加: require('blog/wp-blog-header.php');
然后你想在哪里發布你的帖子:
<article>
<?php
$posts = get_posts('numberposts=1&order=ASC&orderby=post_title');
foreach ($posts as $post) : setup_postdata( $post ); ?>
<?php the_date(); echo "<br />"; ?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?
php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<?php endforeach;?>
</article>
就是這樣......來源: https : //codex.wordpress.org/Integrating_WordPress_with_Your_Website
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.