2017-01-30 4 views
2

ブログ投稿を引き出し、Wordpressフォルダ外にある私のカスタムsingle.phpページに表示する必要があります。パーマリンクを上書きし、Wordpressディレクトリの外に投稿データを表示する

私はindex.phpのページで自分の最新のページのリストを取得していますが、permalinkをクリックするとどこも私に送信されません。 permalink と思っています。これはWordpressフォルダにありますので、そのリンクはそれに関連しています。

私はindex.phpのパーマリンクをクリックして、ユーザをsingle.phpのブログフォルダ外に持ち出し、その投稿を表示します。ここで

は、彼はあなたが私のレイアウトを視覚化するために

マイフォルダ構造私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'); ?> 

答えて

0

あなたはパーマリンクを変更するにはpost_type_linkフィルタを使用することができます。

何かのように:

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

https://developer.wordpress.org/reference/hooks/post_type_link/

関連する問題