简体   繁体   English

子目录中的 WP:如何在 root 中的非 wp 上显示项目

[英]WP in subdirectory: how to show items on non-wp in root

Wordpress is installed in the subdirectory «/blog», and is accessible there. Wordpress 安装在子目录 «/blog» 中,可以在那里访问。 I'm trying to find out how to place the last blog-item as the main article in the non-wp root «index.php».我试图找出如何将最后一个博客项目作为非 wp 根目录 «index.php» 中的主要文章。

All I can find is about WP in subdirectory, and acting if it is in the root, but that's not what I want.我所能找到的只是关于子目录中的 WP,如果它在根目录中就起作用,但这不是我想要的。 The blog must stay in the subdirectory, because the rest of the site is non-WP.博客必须留在子目录中,因为站点的其余部分是非 WP 的。 I know it is possible;我知道这是可能的; I read about it years ago, but I can't find that source anymore.几年前我读过它,但我再也找不到那个来源了。

In root-index add: require('blog/wp-blog-header.php');在根索引中添加: require('blog/wp-blog-header.php');

And then where you want to post your post:然后你想在哪里发布你的帖子:

<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>

That's all... Source: https://codex.wordpress.org/Integrating_WordPress_with_Your_Website就是这样......来源: https : //codex.wordpress.org/Integrating_WordPress_with_Your_Website

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM