Lego2012
9/26/2016 - 10:14 PM

Genesis move Titles above Content

Genesis move Titles above Content

<?php

//Moves titles above content and sidebar and adds a custom CSS class

function siga_add_class( $attr, $class ) {
  $attr['class'] .= ' ' . sanitize_html_class( $class );
  return $attr;
}
// Now the name of the called function tells us what's happening (add a class).
function siga_attr_entry_title( $attr ) {
  return siga_add_class( $attr, ' above' );
}

add_action('get_header', 'move_post_titles');
function move_post_titles() {
// Setting up conditionals for pages where the title shouldn´t be moved
  if (!is_home() && !is_archive() && !is_page('blog') && !is_category()) {
    // Removes entry title
    remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
    // Puts entry title back in after header
    add_action( 'genesis_after_header', 'genesis_do_post_title', 20 );
    // Adds the custom class to entry-title
      add_filter( 'genesis_attr_entry-title', 'siga_attr_entry_title' );

  }
}
h1.entry-title.above {
	text-align:center;
	background:#000000;
	color:#fff;
	padding: 15px 0;
}