2016-11-21 63 views
0

我最近在其中一個博客網站上安裝了WordPress REST API,並一直在使用它來允許我將博客文章引入另一個靜態網站。我一直在使用下面的PHP中的文章及其內容拉:刪除摘錄閱讀更多鏈接WP REST API

<?php 

    $json = file_get_contents('http://news.cribrater.com//wp-json/posts?filter[posts_per_page]=2'); 
    $posts = json_decode($json); 

    foreach ($posts as $p) { 

     echo '<li>'; 
     echo $p->featured_image ? '<figure class="wordpress-loop-bg-image" style="background: url(' . $p->featured_image->guid . ') no-repeat center; background-size: cover; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; ">' : ''; 
     echo '<figcaption><p>' . date('M j, Y', strtotime($p->date)) . '</p> </figcaption></figure>'; 
     echo '<h4><a href="' . $p->link . '">'. $p->title . '</a></h4>'; 
     echo '' . $p->excerpt . ''; 
     echo '</li>'; 

    } 

?> 

我的問題是,我無法弄清楚如何隱藏「更多」鏈接的「摘錄」後出現。我無法編輯WordPress網站功能文件,因爲我需要該網站的「閱讀更多」鏈接,但希望將其隱藏在靜態網站上。

任何幫助,將不勝感激。謝謝。

回答

0

你可以寫

.moretext { 
      display: none 
    } 

或者在你的functions.php使用此功能,寫你想要什麼,或是保留空白。

function modify_read_more_link() { 
    return '<a class="more-link" href="' . get_permalink() . '">Your Read More Link Text</a>'; 
} 
add_filter('the_content_more_link', 'modify_read_more_link'); 

採取在崗看看有很好的答案:https://codex.wordpress.org/Customizing_the_Read_More

+0

感謝。我目前正在使用CSS選項,但一直試圖避免在「read more」鏈接中加載。不幸的是,該功能選項不適合我的任務,因爲我需要將文本顯示在WordPress網站上,而不是在單獨的靜態網站上顯示。 – embigmotive

+0

如果您有其他課程只能在單獨的網站上工作。你可以通過這種方式編寫'.other-class .moretext {display:none}'類.more文件只隱藏在'.other-class'文件中 –