0

I'm using the Genesis Framework and want to have different Pagination for each Custom Post Type (I have two, work and employees). I also have standards posts.

The custom pagination is working for Employees and Work but not for standard posts, the pagination for Employees is showing. Here are the example pages:

Employees:

http://dr.betaforming.com/studio/people/dawn-ter-horst-senior-interior-designer-business-development/

Work:

http://dr.betaforming.com/work/bradley-montgomery/

Standard Posts:

http://dr.betaforming.com/recognition/publicity/2015-monumental-achievement-award-interior-design/

Here is my code:

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 '&nbsp';
        }
        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 '&nbsp';
        }
        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>';

    }
}
0

I figured it out after reviewing the code reference for is_singular some more.

Here is the final code:

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 '&nbsp';
        }
        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 '&nbsp';
        }
        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>';

    }
} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.