Created
June 10, 2017 18:03
-
-
Save srdjan-m/d0a97624c2e1c0c827bea3fccf80acb4 to your computer and use it in GitHub Desktop.
genesis: hide title with custom fields
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
// You need is_title_visible = false custom field in a page or post. | |
// "false" is the only value which will trigger the code to hide a page title. | |
// For posts | |
add_action( 'loop_start', 'remove_titles_all_single_posts' ); | |
function remove_titles_all_single_posts() { | |
if ( is_singular('post') ) { | |
$cust_fld_title_visible = get_post_meta(get_the_ID(), "is_title_visible", true); | |
if ($cust_fld_title_visible == "false") { | |
remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); | |
} | |
} | |
} | |
// For pages | |
add_action( 'get_header', 'remove_titles_all_single_pages' ); | |
function remove_titles_all_single_pages() { | |
if ( is_singular('page') ) { | |
$cust_fld_title_visible = get_post_meta(get_the_ID(), "is_title_visible", true); | |
if ($cust_fld_title_visible == "false") { | |
remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment