The Adding Buttons article shows you how to add buttons in content using some simple HTML and CSS.
Adding a call to action button in the navigation is also achievable with some CSS.
1. Add a custom class to your menu item, for example nav-button
2. Add the CSS:
For primary navigation:
@media (min-width:769px) {
.main-navigation .main-nav ul li.nav-button a {
background-color: #ffffff;
border: 2px solid #000000;
color: #000000; line-height: 35px; /*this number will likely need to be adjusted*/
}
}
For secondary navigation:
@media (min-width:769px) {
.secondary-navigation .main-nav ul li.nav-button a {
background-color: #ffffff;
border: 2px solid #000000;
color: #000000; line-height: 35px; /*this number will likely need to be adjusted*/
}
}
Hooks Visual Guide
Hooks allows us to 「hook」 our own custom code into various areas of the theme without changing core files.
You can see all of the available hooks in GeneratePress here.
The images below provide a visual guideline of where the hooks are located.
Posts Page
Single Post
Static Page
Archives
Using Hooks with Conditional Tags
Our Hooks add-on allows us to 「hook」 our own custom code into various areas of the theme without changing core files.
By default, the content added in hooks will show up on all pages and posts.
We can also use Conditional Tags to show hooks on specific pages.
We will need to Execute PHP for the conditional tags to work.
Here are some common examples:
Blog/Posts Page
This Content will ONLY show on the blog/posts page
This content is EXCLUDED from the blog/posts page
More info on The Main Page.
Static Front Page
This Content will ONLY show on the static front page
This content is EXCLUDED from the static front page
More info on The Front Page.
Latest Posts as Home page
This Content will ONLY show on the latest post page
This content is EXCLUDED from the latest post page
More info on The Blog Page.
Single Posts
This Content will ONLY show in single posts
This content is EXCLUDED from single posts
See more info on A Single Post Page.
Static Pages
This Content will ONLY show in static pages
This content is EXCLUDED from static pages
See more info on A PAGE Page.
Add a Zoom Effect on Hover to Post Images
Here is a cool piece of CSS to achieve this effect:
.post-image {
position: relative;
overflow: hidden;
}
.post-image img {
max-width: 100%;
-moz-transition: all 0.3s;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
.post-image:hover img {
-moz-transform: scale(1.2);
-webkit-transform: scale(1.2);
transform: scale(1.2);
}
Add a Custom Class to the Body Element
If you would like to add a custom class to the body element, use the PHP snippet below:
add_filter( 'body_class','tu_add_body_class' );
function tu_add_body_class( $classes ) {
$classes[] = 'my-custom-body-class';
return $classes;
}
Remove all GP Customizer options
If for some reason you would like to remove all GP customizer options, use the PHP snippet below:
add_action( 'after_setup_theme','tu_remove_customizer_options', 1000 );
function tu_remove_customizer_options( $wp_customize ) {
remove_action( 'customize_register', 'generate_customize_register' );
remove_action( 'customize_register', 'generate_default_fonts_customize_register' );
remove_action( 'customize_register', 'generate_backgrounds_customize', 999 );
remove_action( 'customize_register', 'generate_backgrounds_secondary_nav_customizer', 1000 );
remove_action( 'customize_register', 'generate_blog_customize_register', 99 );
remove_action( 'customize_register', 'generate_colors_customize_register' );
remove_action( 'customize_register', 'generate_colors_secondary_nav_customizer', 1000 );
remove_action( 'customize_register', 'generate_colors_wc_customizer', 100 );
remove_action( 'customize_register', 'generate_copyright_customize_register' );
remove_action( 'customize_register', 'generate_menu_plus_customize_register', 100 );
remove_action( 'customize_register', 'generate_page_header_blog_customizer', 99 );
remove_action( 'customize_register', 'generate_secondary_nav_customize_register', 100 );
remove_action( 'customize_register', 'generate_spacing_customize_register', 99 );
remove_action( 'customize_register', 'generate_fonts_customize_register' );
}
Remove the GP Dashboard for non super admins
If you want to remove the GP Dashboard for non super admins, use the PHP below:
add_filter( 'generate_dashboard_page_capability', 'tu_super_admin_dashboard' );
function tu_super_admin_dashboard() {
return 'manage_sites';
}
The snippet can also be modify for other Roles and Capabilities as you prefer.
Add Entry Meta to Pages
By default, the entry meta (date and author) is only added to posts. If you would like to display entry meta on pages as well, use the PHP snippet below:
add_action( 'generate_after_entry_header', 'tu_page_meta' );
function tu_page_meta() {
if ( 'page' == get_post_type() ) : ?>
<?php endif;
}
Faux Full Screen Page Hero
Starting in GP Premium 1.7, the Full Screen option is only available when Merge with content option is selected. The reason is because Full Screen without having the header merged required javascript and was a little hacky, and it』s not truly full screen if the header isn』t merged.
However, if you would like to size the page hero so it fills the rest of the space below header and navigation, simply add the CSS snippet below:
.page-hero {
min-height: calc(100vh - 200px); /*Modify the 200px to the height of your header*/
}
Don』t know the height of your header or navigation? Start a support topic here and we will be happy to help you out
generate_before_entry_title
The generate_before_entry_title hook appears before the titles of your posts, including the archive and single post templates.
Usage
Please refer to the Using Hooks article to learn how to use this hook.