我正在使用Genesis框架,并希望为每个自定义职位类型(我有两种,工作和员工)提供不同的分页。我也有标准岗位。
自定义分页适用于员工,但不适用于标准职位,显示员工分页。以下是示例页面:
员工:
http://dr.betaforming.com/studio/people/dawn-ter-horst-senior-interior-designer-business-development/
工作:
http://dr.betaforming.com/work/bradley-montgomery/
标准岗位:
http://dr.betaforming.com/recognition/publicity/2015-monumental-achievement-award-interior-design/
这是我的代码:
add_action( \'genesis_entry_footer\', \'dr_prev_next_post_nav\' );
function dr_prev_next_post_nav() {
genesis_markup( array(
\'html5\' => \'<div %s>\',
\'xhtml\' => \'<div class="navigation">\',
\'context\' => \'adjacent-entry-pagination\',
) );
if ( is_singular( array( \'employees\', \'post\' ) ) ) {
echo \'<div class="pagination-previous one-half first alignleft">\';
previous_post_link( \'%link\', \'Previous Employee\' );
echo \'</div>\';
echo \'<div class="pagination-next one-half alignright">\';
next_post_link( \'%link\', \'Next Employee\' );
echo \'</div>\';
echo \'</div>\';
} elseif ( is_singular( array( \'work\', \'post\' ) ) ) {
echo \'<div class="pagination-previous one-third first alignleft">\';
if (strlen(get_previous_post()->post_title) > 0) {
previous_post_link( \'%link\', \'Previous Project\', TRUE, \'\', \'work-type\' );
} else {
echo \' \';
}
echo \'</div>\';
echo \'<div class="one-third content-centered">\';
echo \'<button id="toggle-content" class="project-toggle">Project Description</button>\';
echo \'</div>\';
echo \'<div class="pagination-next one-third alignright">\';
if (strlen(get_next_post()->post_title) > 0) {
next_post_link( \'%link\', \'Next Project\', TRUE, \'\', \'work-type\' );
} else {
echo \' \';
}
echo \'</div>\';
echo \'</div>\';
} else {
echo \'<div class="pagination-previous one-half first alignleft">\';
previous_post_link( \'%link\', \'Previous Publicity Article\' );
echo \'</div>\';
echo \'<div class="pagination-next one-half alignright">\';
next_post_link( \'%link\', \'Next Publicity Article\' );
echo \'</div>\';
echo \'</div>\';
}
}
SO网友:Brett
我在查看了is\\u singular的代码参考之后,又找到了答案。
以下是最终代码:
add_action( \'genesis_entry_footer\', \'dr_prev_next_post_nav\' );
function dr_prev_next_post_nav() {
genesis_markup( array(
\'html5\' => \'<div %s>\',
\'xhtml\' => \'<div class="navigation">\',
\'context\' => \'adjacent-entry-pagination\',
) );
if ( is_singular( array( \'employees\' ) ) ) {
echo \'<div class="pagination-previous one-half first alignleft">\';
previous_post_link( \'%link\', \'Previous Employee\' );
echo \'</div>\';
echo \'<div class="pagination-next one-half alignright">\';
next_post_link( \'%link\', \'Next Employee\' );
echo \'</div>\';
echo \'</div>\';
} elseif ( is_singular( array( \'work\' ) ) ) {
echo \'<div class="pagination-previous one-third first alignleft">\';
if (strlen(get_previous_post()->post_title) > 0) {
previous_post_link( \'%link\', \'Previous Project\', TRUE, \'\', \'work-type\' );
} else {
echo \' \';
}
echo \'</div>\';
echo \'<div class="one-third content-centered">\';
echo \'<button id="toggle-content" class="project-toggle">Project Description</button>\';
echo \'</div>\';
echo \'<div class="pagination-next one-third alignright">\';
if (strlen(get_next_post()->post_title) > 0) {
next_post_link( \'%link\', \'Next Project\', TRUE, \'\', \'work-type\' );
} else {
echo \' \';
}
echo \'</div>\';
echo \'</div>\';
} elseif ( is_singular( \'post\' )) {
echo \'<div class="pagination-previous one-half first alignleft">\';
previous_post_link( \'%link\', \'Previous Publicity Article\' );
echo \'</div>\';
echo \'<div class="pagination-next one-half alignright">\';
next_post_link( \'%link\', \'Next Publicity Article\' );
echo \'</div>\';
echo \'</div>\';
}
}