Skip to content

Instantly share code, notes, and snippets.

@srikat
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save srikat/8a3b09d8c2f7ad8d2ad9 to your computer and use it in GitHub Desktop.
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/
<?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;
}
<?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' );
}
}
<!--nextpage-->
<?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;
}
.paged .entry-header {
display: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment