Last active
August 29, 2015 14:05
-
-
Save srikat/8a3b09d8c2f7ad8d2ad9 to your computer and use it in GitHub Desktop.
Adding body class to paginated pages when using nextpage quicktag in WordPress. http://sridharkatakam.com/add-body-class-paginated-pages-using-nextpage-quicktag-wordpress/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//* Do NOT include the opening php tag | |
//* Add custom body class to the head | |
add_filter( 'body_class', 'sk_body_class' ); | |
function sk_body_class( $classes ) { | |
// If the current page is not a static Page or single Post, move on | |
if ( ! is_page() && ! is_single() ) { | |
return; | |
} | |
// Assign a custom class of "paged" to body element on 2nd paginated page onwards | |
if ( (int) get_query_var( 'page' ) > 0 ) { | |
$classes[] = 'paged'; | |
} | |
return $classes; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//* Do NOT include the opening php tag | |
add_action( 'genesis_before_entry', 'remove_title_paged_pages' ); | |
function remove_title_paged_pages() { | |
// If the current page is not a static Page or single Post, move on | |
if ( ! is_page() && ! is_single() ) { | |
return; | |
} | |
// For 2nd paginated page onwards | |
if ( (int) get_query_var( 'page' ) > 0 ) { | |
//* Remove the entry title | |
remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--nextpage--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//* Do NOT include the opening php tag | |
//* Add custom body class to the head | |
add_filter( 'body_class', 'sk_body_class' ); | |
function sk_body_class( $classes ) { | |
// If the current page is a static Page or single Post AND is not the first Page when paginated | |
if ( ( is_page() || is_single() ) && get_query_var( 'page' ) != 0 ) { | |
$classes[] = 'paged'; | |
} | |
return $classes; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.paged .entry-header { | |
display: none; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment