Skip to content

Instantly share code, notes, and snippets.

@srdjan-m
Created June 10, 2017 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srdjan-m/d0a97624c2e1c0c827bea3fccf80acb4 to your computer and use it in GitHub Desktop.
Save srdjan-m/d0a97624c2e1c0c827bea3fccf80acb4 to your computer and use it in GitHub Desktop.
genesis: hide title with custom fields
// 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