Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 覆盖Permalink并在Wordpress目录外显示Post数据_Php_Wordpress - Fatal编程技术网

Php 覆盖Permalink并在Wordpress目录外显示Post数据

Php 覆盖Permalink并在Wordpress目录外显示Post数据,php,wordpress,Php,Wordpress,我需要拉一篇博客文章并显示在我的自定义single.php页面上,该页面位于Wordpress文件夹之外 我有一个index.php,该页面会列出我最近的页面,但是,单击永久链接不会给我任何信息。permalink认为它在Wordpress文件夹中,所以链接是相对的 我只希望index.php permalinks,单击后,将用户带到我博客文件夹外的single.php,并显示该文章 到目前为止,我已经知道了这些,但我也不知道如何让permalinks将用户发送到我的single.php页面 我

我需要拉一篇博客文章并显示在我的自定义
single.php
页面上,该页面位于Wordpress文件夹之外

我有一个
index.php
,该页面会列出我最近的页面,但是,单击永久链接不会给我任何信息。permalink认为它在Wordpress文件夹中,所以链接是相对的

我只希望index.php permalinks,单击后,将用户带到我博客文件夹外的
single.php
,并显示该文章

到目前为止,我已经知道了这些,但我也不知道如何让permalinks将用户发送到我的
single.php
页面

我的文件夹结构可帮助您可视化我的布局

+ /blog/
    - All the standard wordpress stuff in this folder
- index.php (shows recent)
- single.php (where I want the user to go)
single.php

<?php include_once('_header.php');
require_once(constant('ROOT') . '/blog/wp-load.php'); 
 ?>   
    <div class="row">
        <div class="col-sm-12">
            <?php 
                if ( have_posts() ) : while ( have_posts() ) : the_post();
                    get_template_part( 'content-single', get_post_format() );
                    if ( comments_open() || get_comments_number() ) :
                        comments_template();
                    endif;
                endwhile; endif; 
            ?>
        </div> <!-- /.col -->
    </div> <!-- /.row -->
    <hr/>
<?php include_once('_footer.php'); ?>  



您可以使用post\u type\u链接过滤器更改永久链接

比如:

add_filter('post_type_link', 'custom_links')

function custom_links($post_link, $post) {
    if (some conditions of $post) {
        str_replace("what you want to replace", "it's replacement", $post_link)
    }
return $postlink;
}