2017-02-08 38 views
0

我嘗試從帖子導航中排除某些類別(next_post_link和previous_post_link),但它不起作用。我需要幫助。如何從next_post_link和previous_post_link(Wordpress)中排除某些類別?

我想爲這個函數使用functions.php。

有從「類別的Widget」排除類別一個不錯的功能:

function ds_exclude_widget_categories($args) { 
    $exclude = '1,26,28'; 
    $args['exclude'] = $exclude; 
    return $args; 
} 
add_filter('widget_categories_args', 'ds_exclude_widget_categories'); 

怎麼會這樣的功能看起來想排除後導航類別?

問候, 塞巴斯蒂安

回答

1

next_post_linkprevious_post_link已經有論據,不計特殊項目https://codex.wordpress.org/Function_Reference/next_post_link

所以,如果你希望只排除ID號爲13類,從你的鏈接,你應該使用類似

<?php next_post_link('%link', 'Next post in category', FALSE, '13'); ?> 
+0

嗨Ed Dogan,謝謝你的幫助。 – sk77

+0

我不想更改主題中的文件,也不想創建子主題。我想將它作爲functions.php中的過濾器。那可能嗎? – sk77

相關問題