generate_site_title_output

generate_site_title_output

The generate_site_title_output allows allows us to alter the HTML of our site title.

Example

If we don』t want a link surrounding the title:

add_filter( 'generate_site_title_output', function( $output ) {
return sprintf(
'
%3$s
',
( is_front_page() && is_home() ) ? 'h1' : 'p',
esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
get_bloginfo( 'name' )
);
});

Removing an Imported Site

Removing an Imported Site

If you install a Site and decide you don』t want it, or you want to install a different one, head back into the main Site Library page and you』ll see the below message.

When you import a site, we take a quick backup of your existing settings first. If you decide to remove the imported site, we will restore those settings we took a backup of.

The removal process does make changes to your database, so if you have data you don』t want to risk losing, please take a site backup before doing this process.

It is possible to click the 「Skip」 link and install another site on top of the site you already imported. However, remember that the backup is taken as you import a site, so if you import on top of another import, you will be taking a backup of the previously imported site. This means you won』t be able to go back to how your site was before the first site import.

Changing the Title of an Archive Page

Changing the Title of an Archive Page

By default, the archive page title is simply the name of the category or tag.

If you want to use a custom title instead, try this PHP snippet:

add_filter( 'get_the_archive_title', function( $title ) {
if ( is_category( 'CATEGORY NAME' ) ) {
$title = 'YOUR CUSTOM TITLE';
}

return $title;
}, 50 );

See more information on WordPress Conditional Tags.

Exclude Tags from Posts page

Exclude Tags from Posts page

Some users would like to exclude certain tags from the posts page. This can be done with the following PHP snippet:

function exclude_posts( $query ) {
if ( $query->is_home() ) {
$query->set( 'tag__not_in', array( 13 , 26 ) );
}
}
add_action( 'pre_get_posts', 'exclude_posts' );

Simply edit your tag IDs in there instead of the 13 and 26 (examples).

generate_post_author_output

generate_post_author_output

This filter returns the HTML that displays your post author along with your blog posts.

You can use this filter to completely overwrite the HTML given, or even add to it.

Add an Icon

For example, if you wanted to add an author icon before your author name, you could do this:

add_filter( 'generate_post_author_output', function( $output ) {
return ' ' . $output;
} );

Remove from Post Type

Another example is if you want to remove the author on a specific post type, but keep it elsewhere:

add_filter( 'generate_post_author_output', function( $output ) {
// If we're on our "my-post-type" post type, remove the author.
if ( is_post_type_archive( 'my-post-type' ) || 'my-post-type' == get_post_type() ) {
return '';
}

// Otherwise, display it.
return $output;
} );

Custom Author Name

One more example is if you want to completely customize your author name and link:

add_filter( 'generate_post_author_output', function( $output ) {
return 'My Name';
} );

Remove Link

Lastly, if you want to remove the link from the author:

add_filter( 'generate_post_author_output', function() {
printf( ' ',
sprintf( '%1$s %4$s',
__( 'by','generatepress'),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ),
get_the_author() ) ),
esc_html( get_the_author() )
)
);
} );

generate_hook_element_display

generate_hook_element_display

The generate_hook_element_display allows us to bypass the Display Rules, so we can enable or disable an Element under our own conditions.

For example, if we want to assign a specific hook to Author Tom only:

add_filter( 'generate_hook_element_display', function( $display, $element_id ) {
if ( 10 === $element_id && is_author( 'Tom' ) ) {
$display = true;
}

return $display;
}, 10, 2 );

Another useful example is to set the hook to display on the parent page and all the child pages automatically:

add_filter( 'generate_hook_element_display', function( $display, $element_id ) {
global $post;

if ( 1180 === $element_id && ( is_page() && $post->post_parent == '415' ) ) {
$display = true;
}

return $display;
}, 10, 2 );

You need to replace 1180 with the ID of your Element, and 415 with the ID of the parent page.

Font Awesome

Font Awesome

GeneratePress no longer includes Font Awesome directly in the theme. Instead, you should use the official Font Awesome plugin to add it to your site when needed.

Old Theme Version

If you』re still using the Font Awesome 4 version that was included in the theme, you can remove it super easily by going to Customize > General and checking the Load essential icons only option.

Once this option is checked and saved, it will disappear the next time you load the Customizer.