Last active
April 12, 2022 07:36
-
-
Save robincornett/cca2a45f273b35399bd2 to your computer and use it in GitHub Desktop.
optional home.php--to show the posts (blog) page's title and content
This file contains hidden or 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 line! Just add what's below to the end of your functions.php file | |
add_action( 'edit_form_after_title', 'rgc_posts_page_edit_form' ); | |
function rgc_posts_page_edit_form( $post ) { | |
$posts_page = (int) get_option( 'page_for_posts' ); | |
if ( $posts_page === $post->ID ) { | |
add_post_type_support( 'page', 'editor' ); | |
} | |
} |
This file contains hidden or 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 | |
/** | |
* Blog Intro | |
* | |
*/ | |
remove_action( 'genesis_before_loop', 'genesis_do_posts_page_heading' ); | |
add_action( 'genesis_before_loop', 'rgc_blog_intro' ); | |
function rgc_blog_intro() { | |
$posts_page = get_option( 'page_for_posts' ); | |
if ( is_null( $posts_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 class="archive-title">%s</h1>', $title ); | |
if ( class_exists( 'Display_Featured_Image_Genesis' ) ) { | |
$common = new Display_Featured_Image_Genesis_Common(); | |
$item = $common->get_image_variables(); | |
$large = absint( get_option( 'large_size_w' ) ); | |
if ( $item->backstretch && $item->backstretch[1] > $large ) { | |
$title_output = ''; | |
} | |
} | |
} | |
if ( $content ) { | |
$content_output = wpautop( $content ); | |
} | |
if ( class_exists( 'Display_Featured_Image_Genesis' ) && ! $content ) { | |
return; | |
} | |
elseif ( $title || $content ) { | |
printf( '<div class="archive-description">%s</div>', $title_output . $content_output ); | |
} | |
} | |
genesis(); |
This file contains hidden or 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 | |
/** | |
* Blog Intro | |
* | |
*/ | |
remove_action( 'genesis_before_loop', 'genesis_do_posts_page_heading' ); | |
add_action( 'genesis_before_loop', 'rgc_blog_intro' ); | |
function rgc_blog_intro() { | |
$posts_page = get_option( 'page_for_posts' ); | |
if ( is_null( $posts_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 class="archive-title">%s</h1>', $title ); | |
} | |
if ( $content ) { | |
$content_output = wpautop( $content ); | |
} | |
if ( $title || $content ) { | |
printf( '<div class="archive-description">%s</div>', $title_output . $content_output ); | |
} | |
} | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment