2014-10-20 26 views
1

當我在其中一個網站帖子的底部點擊「閱讀更多」時,它只是將其餘文本加載到同一頁面和同一部分,從而使文本和破壞我的佈局。我注意到,在每個Wordpress帖子末尾有一個<!--more-->標籤,當從工具欄添加「閱讀更多內容」時。如何覆蓋此標記的默認行爲,以便在用戶單擊「更多...」以查看帖子時打開新頁面? 更新:
發佈內容使用jQuery代碼從名爲tazeha.php的php文件中加載。
tazeha.php
如何更改<!--more--> Wordpress中的行爲

<html> 
<head> 
    <link rel="stylesheet" type="text/css" href="style.css"/> 
    <?php 
    require('wp-config.php'); 
    ?> 
</head> 
<body> 




<?php 
      $cat_id=get_cat_ID('تازه ها'); 
       $posts = get_posts ("cat=$cat_id&posts_per_page=1"); 
       if ($posts) 
      { 
      foreach ($posts as $post): 
       setup_postdata($post); ?> 
       <h2><?php the_title(); ?></h2> 
       <?php the_content();?> 
       <?php endforeach; 
      } 
?> 


</body> 
</html> 

我可以改變上面的代碼,這樣一個帖子「的」標籤後的文本在新的瀏覽器頁面(標籤)打開了?

+1

你應該在這裏http://wordpress.stackexchange.com/發佈的WordPress問題 – KRUKUSA 2014-10-20 08:22:36

+0

謝謝,BU我想這可能更多的是PHP的問題,而不是wordpress的。 – JasonStack 2014-10-20 08:23:27

+0

然後我們需要看到php代碼。 – KRUKUSA 2014-10-20 08:23:55

回答

2

Stackoverflow post後,我添加了一個single.php到我的主題文件夾中,下面的代碼工作完美,即當我點擊「閱讀更多...」鏈接時,我的完整文章內容會顯示在新頁面中帖子。
的single.php

<div id="primary" class="content-area"> 
    <div id="content" class="site-content" role="main">   
    <?php while (have_posts()) : the_post(); ?> 
    <h3><?php the_category('&nbsp;&rsaquo;&nbsp;'); echo "&nbsp;&rsaquo;&nbsp;"; the_title(); ?></h3> 
    <?php the_content(); ?> 
    <?php endwhile; // end of the loop. ?> 
    </div><!-- #content --> 
</div><!-- #primary -->