Exclude Categories from Posts page

Exclude Categories from Posts page

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

add_filter('pre_get_posts', 'excludeCat');
function excludeCat($query) {
if ( $query->is_home ) {
$query->set('cat', '-3,-5,-23');
}
return $query;
}

Simply add your category IDs in there instead of the 3, 5 and 23 (examples) and keep the minuses in there.

Show Secondary Navigation to Logged In Users Only

Show Secondary Navigation to Logged In Users Only

Some users would like to hide the secondary navigation from unregistered visitors and display to logged in users only. This can be done with the following PHP snippet:

add_filter( 'has_nav_menu', 'tu_disable_secondary_nav_logged_out', 10, 2 );
function tu_disable_secondary_nav_logged_out( $has_nav_menu, $location ) {
if ( 'secondary' === $location && ! is_user_logged_in() ) {
return false;
}

return $has_nav_menu;
}

generate_hooks_execute_php

generate_hooks_execute_php

The generate_hooks_execute_php allows you to overwrite DISALLOW_FILE_EDIT and execute PHP within the Hooks Element.

However, it is recommended that if DISALLOW_FILE_EDIT is defined, then you should disable PHP execution in Hooks Element. Likewise, if you disable PHP execution in Hooks Element, you should define DISALLOW_FILE_EDIT as well.

If you do wish to overwrite it for some reason, add the following PHP snippet:

add_filter( 'generate_hooks_execute_php', '__return_true' );

Hooks Overview

Hooks Overview

GeneratePress uses the WordPress Hooks API to insert actions throughout the theme.
This 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 Hooks add-on makes it easier for you to add content into many of the main hooks without the need to write any PHP.
To find the Hooks area, go to Appearance > GP Hooks.
If you need a visual reference of where these hooks are located, check out this page.
Execute PHP
If you』ve added PHP into your hook, you must check the Execute PHP checkbox in order for it to work.
Disable Hook
If you need to, you can check the Disable Hook option to stop the hook from inserting into the page.
Video Overview

WordPress Hosting

WordPress Hosting

WordPress hosting is necessary for every self-hosted WordPress site. It acts as a home for your website and gives your domain name somewhere to point to so people can actually reach your site.

The below are a few of our favorite hosting companies. The links are affiliate links, but we actually use and recommended all of these companies, and we know they work great with WordPress and GeneratePress.

Kinsta is premium WordPress hosting. We use them here at GeneratePress, and everything they do is next level. Their servers are incredibly fast, and their support is better than any other hosting company by a decent margin. They aren』t as affordable as the other options on this page, but if you can afford them, they』re worth every penny.

Learn More

If you』re looking for a solid WordPress host, SiteGround is worth looking at. They offer a variety of plans, including very affordable ones for people just starting out. They have a great reputation among the WordPress community.

Learn More

Cloudways is another quality option when it comes to hosting. They are a managed host where you can choose your own type of server from providers like Digital Ocean (and many others). This gives you full control over your server specs, but allows them to take care of all of the actual server maintenance.

Learn More

Plugin Install Failed

Plugin Install Failed

Receiving this error?:
The package could not be installed. No valid plugins were found.
Plugin install failed.
You』re most likely trying to install the free theme (generatepress.zip) as a plugin.
Instead, head over to your account and download GP Premium (gp-premium.zip), then install it as a plugin.
Check out this article to learn more on how to install GP Premium.

Missing style.css

Missing style.css

When you purchase GP Premium, you may assume that it』s a theme which you need to install via the 「Themes」 area of your WordPress Dashboard. Doing so will result in an error telling you that the theme is missing the style.css stylesheet.
This is happening because GP Premium is actually a plugin.
This means you need to upload it through the 「Plugins」 area of the Dashboard.
For step by step instructions on how to install GP Premium, check out this article.

option_generate_menu_plus_settings

option_generate_menu_plus_settings

The option_generate_menu_plus_settings filter allows you to filter the options in our Menu Plus add-on.
These options are all available in the customizer. The filters allow you to change the setting under certain conditions.

Available Options

Return Value

mobile_menu_label
Set the text of your mobile menu label.

'My custom mobile menu label'

sticky_menu
Activate or disable sticky navigation.

'mobile' //mobile only
'desktop' //desktop only
'true' //both
'false' //disable

sticky_menu_logo
The URL to your navigation logo.

'URL to image'

sticky_menu_effect
Set the sticky navigation transition.

'fade'
'slide'
'none'

auto_hide_sticky
Hide the sticky navigation unless you』re scrolling up towards the top of the site.

'true'
'false'

sticky_menu_logo_position
Set the navigation logo position.

'sticky-menu' //Sticky only
'menu' //Sticky + static
'regular-menu' //Static only

mobile_header
Activate or disable the mobile header.

'disable'
'enable'

mobile_header_sticky
Activate or disable the sticky mobile header.

'disable'
'enable'

mobile_header_auto_hide_sticky
Hide the sticky mobile header unless you』re scrolling up towards the top of the site.

'true'
'false'

slideout_menu
Activate or disable slideout navigation.

'mobile' //Mobile only
'desktop' //Desktop only
'both' //On
'false'//Off

slideout_menu_side
Set the side which the slideout navigation opens from.

'left'
'right'

Example
If we want to use different settings for static home page:
add_filter( 'option_generate_menu_plus_settings','lh_custom_homepage_menu_plus_settings' );
function lh_custom_homepage_menu_plus_settings( $options ) {
if ( is_front_page() ) {
$options['mobile_menu_label'] = 'Home Page Toggle Text';
$options['sticky_menu'] = 'off';
$options['mobile_header'] = 'enable';
$options[『mobile_header_sticky』] = 'enable';
$options[『mobile_header_auto_hide_sticky』] = 'false';
}

return $options;
}