GeneratePress Customizing

Recently I switched to the modern and clean GeneratePress Theme. It has a great documentation and development spirit as well.

If you want to customize your theme and e.g. edit the functions.php or use some add_shortcode() functionality for your WordPress installation, the first thing you have to do is to create a child theme. Otherwise changes get overwritten if the theme gets upgraded with the WordPress backend. The process is straight forward and documented here.

After that any editing will be done in the folder generatepress_child and the child theme needs to be the activated theme. I will document some snippets of my functions.php in order to customize the theme.

Remove not needed headers and WordPress version information

// remove head links
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'wp_shortlink_wp_head');

Remove HTTP and HTML pingback header

// remove pingback
function generate_pingback_header() { }
add_action('wp', function() {
}, 1000);

Change GeneratePress Footer

// footer
add_action( 'generate_credits', 'generate_add_footer_info' );
function generate_add_footer_info() { ?>
<span class="copyright">© 2008-<?php echo date( 'Y' ) . " "; echo get_bloginfo( 'name' ) ?></span>
<?php }

Add a Font or any other HTML head

// add font
function add_font() { ?>
<link href="<?php bloginfo('url'); ?>/wp-content/fonts/noto-serif-v9-latin/style.css" rel='stylesheet' type='text/css' />
<?php }

Don't show / remove post author

// don't show author
add_filter( 'generate_post_author_output', function( $output ) {
  return '';
} );

Redirect author pages to homepage

// redirect author pages to home
add_action('template_redirect', 'redirect_author_pages');
function redirect_author_pages() {
  global $wp_query;
  if ( is_author() ) {
    wp_redirect(get_option('home'), 301);

Remove URL for (new) comments

// remove url for comments
add_action( 'after_setup_theme', 'tu_add_comment_url_filter' );
function tu_add_comment_url_filter() {
  add_filter( 'comment_form_default_fields', 'tu_disable_comment_url', 20 );
function tu_disable_comment_url($fields) {
  return $fields;

If you want to remove the URL for existing comments as well you have to remove those from the SQL database, since the information is already in. This only prevents to add URLs for new comments.
The following SQL statement remove the URL from all comments which are possibly not a pingback (those always have an URL set, but not an email). Take a backup before and check the result!

UPDATE wp_comments SET comment_author_url = '' WHERE comment_author_email != '';

Schreibe einen Kommentar