-
-
Save davidperezgar/ef246b6be40d8db66215f29c4fc5a5b4 to your computer and use it in GitHub Desktop.
Add Content below Title for Posts page inside div.posts-page-description in Genesis. https://sridharkatakam.com/adding-content-title-inside-div-posts-page-description-genesis/
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
// Bring back the missing editor for Posts page | |
add_action( 'edit_form_after_title', 'rgc_posts_page_edit_form' ); | |
function rgc_posts_page_edit_form( $post ) { | |
$posts_page = get_option( 'page_for_posts' ); | |
if ( $posts_page === $post->ID ) { | |
add_post_type_support( 'page', 'editor' ); | |
} | |
} | |
remove_action( 'genesis_before_loop', 'genesis_do_posts_page_heading' ); | |
add_action( 'genesis_before_loop', 'sk_do_posts_page_heading' ); | |
/** | |
* Add custom headline and page content to assigned posts page. | |
* | |
* If we're not on a posts page, then nothing extra is displayed. | |
* | |
* @since 2.2.1 | |
* | |
* @return null Return early if `headings` is not enabled for Genesis accessibility, there is no | |
* page for posts assigned, this is not the home (posts) page, or this is not the page found at `/`. | |
*/ | |
function sk_do_posts_page_heading() { | |
if ( ! genesis_a11y( 'headings' ) ) { | |
return; | |
} | |
$posts_page = get_option( 'page_for_posts' ); | |
if ( is_null( $posts_page ) ) { | |
return; | |
} | |
if ( ! is_home() || genesis_is_root_page() ) { | |
return; | |
} | |
$title = get_post( $posts_page )->post_title; | |
$content = get_post( $posts_page )->post_content; | |
$title_output = $content_output = ''; | |
if ( $title ) { | |
$title_output = sprintf( '<h1 %s>%s</h1>', genesis_attr( 'archive-title' ), get_the_title( $posts_page ) ); | |
} | |
if ( $content ) { | |
$content_output = wpautop( $content ); | |
} | |
if ( $title || $content ) { | |
printf( '<div %s>', genesis_attr( 'posts-page-description' ) ); | |
if ( $title ) { | |
printf( '<h1 %s>%s</h1>', genesis_attr( 'archive-title' ), get_the_title( $posts_page ) ); | |
} | |
echo '<div class="posts-page-intro">'. $content_output .'</div>'; | |
echo '</div>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment