2014-01-16 27 views
0

我在我的主頁中有一些鏈接,我想迫使它們在index.php而不是single.php中打開。我如何強制循環/鏈接使用Index.php而不是Single.php

這可能嗎?

<div id="RightBar"> 
<?php query_posts('category_name=new_publish&showposts=100'); ?> <?php while (have_posts()) : the_post(); ?> 
    <a class="Publish_Num" href="<?php echo get_post_permalink(); ?> "> 
     <?php echo rwmb_meta('_mb_monthly_number'); ?> 
    </a> 
<?php endwhile;?> 
</div> 

<?php wp_reset_query() ?> 
+0

你是什麼意思與「我要強迫他們打開?」。 –

回答

0

如果你剛纔的意思是一個單一的頁面重定向使用id = $postid索引頁那麼這將做到: -

function redirect_postid_to_index() { 
    if(is_single('$postid')){ 

     header(bloginfo('url')); 
     exit; 

     } 
    } 

    add_action('init','redirect_postid_to_index'); 
+0

我不希望重定向到索引頁的帖子數量不變。它會因爲每月發佈的數量而增加。所以一個月後,我會有一個新的帖子,我想重定向到index.php。 –

+0

然後您可以爲此創建一個模板,然後您可以將該模板分配給每個帖子。該模板將包含重定向代碼。 – codepixlabs

相關問題