Skip to content

Instantly share code, notes, and snippets.

@incidunt
Created March 4, 2019 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save incidunt/afe80512fb8d592f63130362b852bdbb to your computer and use it in GitHub Desktop.
Save incidunt/afe80512fb8d592f63130362b852bdbb to your computer and use it in GitHub Desktop.
add_action( 'genesis_entry_footer', 'genesis_exlained_post_nav' );
function genesis_exlained_post_nav() {
// 只有在添加了 genesis-explained 这个tag的文章中才执行,否则直接返回
if ( ! ( is_single() && has_tag('genesis-explained') ) ) {
return;
}
genesis_markup(
array(
'open' => '<div %s>',
'context' => 'adjacent-entry-pagination',
)
);
// 返回同一个分类中的上一篇文章,如果没有则为false,显示链接改为“本系列上一篇”
$preious_in_same_taxonomy = get_previous_post_link('%link', '本系列上一篇', TRUE);
genesis_markup(
array(
'open' => '<div %s>',
'context' => 'pagination-previous',
'content' => $preious_in_same_taxonomy ? $preious_in_same_taxonomy: "已是最前", // 根据条件来显示“本系列上一篇”或“已是最前”
'close' => '</div>',
)
);
genesis_markup(
array(
'open' => '<div %s>',
'context' => '',
'content' => '<a>目录</a> ' ,
'close' => '</div>',
)
);
// 返回同一个分类中的下一篇文章,如果没有则为false,显示链接改为“本系列下一篇”
$next_post_in_same_taxonomy = get_next_post_link( '%link', '本系列下一篇',TRUE );
genesis_markup(
array(
'open' => '<div %s>',
'context' => 'pagination-next',
'content' => $next_post_in_same_taxonomy ? $next_post_in_same_taxonomy : '已是最后', // 根据条件来显示“本系列下一篇”或“已是最后”
'close' => '</div>',
)
);
genesis_markup(
array(
'close' => '</div>',
'context' => 'adjacent-entry-pagination',
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment