2009-11-30 49 views
0

我想自定義一個/上一個帖子分頁鏈接到此結構:有沒有辦法只寫下一個/上一篇文章WordPress的鏈接?

<!--PAGINATION--> 
<a href="#prev_post_link#" id="pagePrev" class="button"><span>&laquo; Önceki</span></a> 
<a href="#next_post_link#" id="pageNext" class="button"><span>Sonraki &raquo;</span></a> 
<!--/PAGINATION--> 

所以我想呼應僅次於/前面的帖子鏈接#prev_post_link##next_post_link#用於構建自定義下一個/上分頁

+0

«?這是一個引號,請不要將它用作UTF-8藝術! (這是未來帶給我們的,誰需要ASCII藝術呢?) – Quentin 2009-11-30 14:23:26

+0

我明白你的意思。但我現在會使用它。 :) – fatihturan 2009-11-30 14:44:25

回答

0

我解決了這個問題,JS:

$('div#pagination').ready(function() { 
    if ($('div#pagination a').length == 1 && $('div#pagination a').text() == 'Sonraki »') { 
     $('div#pagination a').before('<a href="javascript:;" class="button"><span>« Önceki</span></a>'); 
     $('div#pagination a:first').css('opacity', '.5'); 
    } 
    if ($('div#pagination a').length == 1 && $('div#pagination a').text() == '« Önceki') { 
     $('div#pagination a').after('<a href="javascript:;" class="button"><span>Sonraki »</span></a>'); 
     $('div#pagination a:last').css('opacity', '.5'); 
    } 
    }); 
0

http://codex.wordpress.org/Function_Reference/previous_post有一些例子。我在我的一個網站中使用以下內容。

<?php previous_post_link('<p id="next-link">%link</p>', 'Next Post, TRUE); ?> 

鏈接由%鏈接表示。你可以添加你的類或包裝。我不認爲你可以直接在沒有核心黑客的情況下直接設計標籤到Wordpress。

使用包裝ID可以實現任何需要的造型。在我的例子中,可以在css中使用樣式

p#next-link a {} 

希望這會有所幫助。

+0

此功能已棄用。這也不能解決我的問題。 – fatihturan 2009-11-30 13:32:39

0

您可以使用get_adjacent_post()。

例子:

$prev_post = get_adjacent_post(false, '', true); 
$prev_post_link = ($prev_post ? get_permalink($prev_post->ID) : ""); 
$next_post = get_adjacent_post(false, '', false); 
$next_post_link = ($next_post ? get_permalink($next_post->ID) : ""); 
+0

你能解釋一下嗎? – fatihturan 2009-11-30 13:30:58

+0

但我不在single.php上工作。我正在研究「自定義頁面模板」。(http://pastie.org/private/ynhgmlii1nssswgotyaa5w) – fatihturan 2009-11-30 14:38:00

0

有一種方法做你在找什麼在你的主題模板 - 但我也有好運氣瓦特/這個插件 - http://wordpress.org/extend/plugins/wp-pagenavi/

如果您仍之後沒有任何運氣,評論回&我會發布代碼。

+0

另外,請查看此文檔 - http://codex.wordpress.org/Template_Tags/previous_posts_link& http://codex.wordpress.org/Template_Tags/next_posts_link 希望這會刺激你的一些想法 – Schoffelman 2009-12-10 23:50:17

相關問題