2013-03-18 37 views

回答

0

更改data-href在每個用法的div。你可以將其設置爲一個元素的ID或交的數量,使它們各不相同:

<div class="fb-comments" data-href="http://yourwebsite.com/#postIDorNumber" data-width="470" data-num-posts="10"></div> 
<div class="fb-comments" data-href="http://yourwebsite.com/#postIDorNumber2" data-width="470" data-num-posts="10"></div> 
<div class="fb-comments" data-href="http://yourwebsite.com/#postIDorNumber3" data-width="470" data-num-posts="10"></div> 

應該很容易落實到一個博客的帖子ID動態地添加到data-href

+0

因此基於你,我想元素ID – Thefirstkilla 2013-03-18 21:36:11

+0

所以數據HREF = 「http://yourwebsite.com/#element ID」 Dropbox的鏈接??? – Thefirstkilla 2013-03-18 21:36:39

+0

每個評論必須有一個獨特的'數據href' ..你可以做任何你喜歡的任何組合。只要它讓你訪問相關頁面'data-href ='http:// www.yoursite.com/blog/pageID.html#elementID-fb-comments-unique-whatever'。如果評論只會在博客入口頁面和每頁一個評論框中,我會堅持使用後的url:'data-href =「http://www.yoursite/blog-post-4.html」 ' – kingkode 2013-03-18 21:39:10

0

的代碼,該Facebook頁面生成是這樣的:

<div class="fb-comments" data-href="http://example.com" data-width="470" data-num-posts="10"></div> 

我reccomend給每個帖子一個單獨的URL表示: /博客/食品/我夾心 /博客/食品/我的雞,油炸餅

只需在呈現帖子列表時更改data-href參數。

例如:

<?php 
foreach($posts as $post) { 
    echo '<div class="post">'; 
    echo '<div class="post-title">' . $post->title . '</div>'; 
    echo '<div class="post-content">' . $post->content . '</div>'; 
    echo '<div class="post-comments"><div class="fb-comments" data-href="http://yoursite.com/blog/' . $post->url . '" data-width="470" data-num-posts="10"></div></div>'; 
    echo '</div>'; 
} 
?> 
+0

對不起,花了這麼長時間我把一張圖片鏈接起來?我將如何爲每個「帖子」創建鏈接?所有的帖子都將是一頁 – Thefirstkilla 2013-03-18 21:38:21

+0

剛纔解釋說給你配偶?這是一個讓一個不同的URL放入div的'data-href'參數的例子,這個參數將永久地代表帖子。 – freshnode 2013-03-18 21:39:50

+0

我看到我想在頁面上發佈多個帖子 – Thefirstkilla 2013-03-18 21:53:41

相關問題