Setting Up a Simple Custom Post Type

Setting Up a Simple Custom Post Type

Here are the quick steps to take when implementing a custom post type in GeneratePress.

1. Register your custom post type

You can either use the full method WordPress provided here:https://developer.wordpress.org/plugins/post-types/registering-custom-post-types/Or a use one of the tools like these:https://generatewp.com/post-type/https://en-ca.wordpress.org/plugins/custom-post-type-ui/This sets the parameters of what the CPT can do, the slug for the templates to be used and where its displayed in the Dashboard Menu.

2. Acquire the templates

Take a copy of the single.php and the content-single.php, then rename them to they match the slug of your CPT tag like single-project.php and content-project.php.

3. Update the single-project.php file

In the single-project.php file, replace this line with the following:

get_template_part( 'content', 'project' );

4. Edit the content-project.php file

Now you are ready to edit the content-project.php file if you need to adjust the structure at all.

generate_menu_bar_items

generate_menu_bar_items

The generate_menu_bar_items hook allows you to hook non-menu item elements such as buttons, icons and whatever else your design requires. Content added there will automatically display in the navigation and mobile header.

Using a Hook Element

If you have GP Premium, you can use a hook element and add the content like this:


Your icon HTML

Using a Function

If you are using the free GeneratePress theme, you can use the PHP snippet method:

add_action( 'generate_menu_bar_items', function() {
?>

Your icon HTML

<?php
} );

generate_svg_icon_element

generate_svg_icon_element

The generate_svg_icon_element filter allows change the default icons used throughout the theme.

The available options are:

menu-bars
close
search
categories
tags
comments
arrow
arrow-right
arrow-left
arrow-up

For example, if you want to use a custom navigation search icon to replace the default one, then this function can be used:

add_filter( 'generate_svg_icon_element', function( $output, $icon ) {
if ( 'search' === $icon ) {
$output = 'Your-custom-search-icon';
}
return $output;
}, 10, 2 );

Make sure to only replace your-svg-here with the actual SVG code in the snippet above.

Debug Mode Enabled

Debug Mode Enabled

When using the Site Library, you may see a message like this:

Having WP_DEBUG enabled during the import process may cause issues if the plugins being imported have any PHP notices or errors.

In order to ensure a smooth import process, it』s a good idea to set WP_DEBUG to false.

To do so, find your wp-config.php file in the root folder of your website via FTP or File Manager, and set WP_DEBUG to false. Save the file, then refresh the Site Library and proceed with your import.

Content Separator

Content Separator

This option requires the Spacing module in GP Premium.

You can adjust the content separating space in Appearance > Customize > Layout > Container.

This option allows you to adjust the space between the featured image, title, content and entry meta.

The value you see is in EM.

Dynamic Blocks

Dynamic Blocks

Starting in GP Premium 2.0, there are two dynamic blocks that are available in the Block Elements module.

You can access them by searching keyword GP in the Add Block menu:

Dynamic Image

The GP Dynamic Image block allows you to add a featured image or an author avatar to the Block Elements.

Featured Image

This option outputs the featured image of the chosen condition.

Type

Set the GP dynamic image block type.

Source

Set the source of the featured image. The Next post and Previous post options are main used for the Post Navigation templates.

Image size

Set the size of the featured image. The sizes are defined in the Media settings section of WordPress.

Image width

Set the width of the image in pixel.

Image height

Set the height of the image in pixel.

Link to

Add a link for the dynamic featured image.

Author Avatar

This option outputs the author avatar.

Type

Set the GP dynamic image block type.

Image Size

Set the height and width of the author avatar.

Make image rounded

Make the author avatar into a circular shape.

Dynamic Content

The GP Dynamic Content block allows you to add post content, post excerpt, term description and author description to Block Elements.

Post Content

This option outputs the entire post content.

Post Excerpt

This option outputs the excerpt of the post with excerpt length field.

Term Description

This option outputs term description like category or tag description.

Author Description

This option outputs author description.

generate_svg_icon

generate_svg_icon

The generate_svg_icon filter allows you to overwrite the entire HTML output of the icon, including the surrounding gp_icon element.

For example, if you want to change the default menu cart icon to a custom icon, then this snippet can be used:

add_filter( 'generate_svg_icon', function( $output, $icon ) {
if ( 'shopping-cart' === $icon ) {
$svg = '

';

return sprintf(
'
%2$s
',
$icon,
$svg
);
}

return $output;
}, 15, 2 );

Centering Your Logo In the Navigation

Centering Your Logo In the Navigation

Centering the logo with menu items on both side is super easy with GeneratePress.

First, make sure you are using the Flexbox structure of the theme. This can be checked in Customizer > General.

Then you can either set the navigation location option to float left/right or use the navigation as a header option.

Next, add the CSS here:

@media(min-width: 769px) {
.inside-header>.site-branding,
.inside-header>.navigation-branding,
.inside-header>.site-logo,
.site-branding-container,
#site-navigation .navigation-branding .site-logo,
#sticky-navigation .navigation-branding {
position: absolute;
left: 50%;
transform: translateX(-50%);
z-index: 1000;
}

#site-navigation {
margin-left: unset !important;
display: flex;
}

.site-header .main-navigation:not(#sticky-navigation) .inside-navigation {
margin: unset;
}

#site-navigation,
#primary-menu,
.main-navigation .inside-navigation {
flex: 1;
}

/* Change nth-child(#) to first item to right */
.main-navigation ul li:nth-child(3) {
margin-left: auto;
}
}

GeneratePress and GP Premium

GeneratePress and GP Premium

GeneratePress – Free Theme

Latest Version: 3.1

Your installed Version: Check Appearance > Themes.

How to Install: Through Appearance > Themes. Details

How to Update: Through Appearance > Themes. Details

Free Support Forum

GP Premium – Premium Plugin

Latest Version: 2.1.1

Your installed Version: Check Dashboard > Plugins.

How to Install: Through Dashboard > Plugins. Details

How to update: Auto-update when activated. Details

Premium Support Forum

Using the Premium Support Forum

Using the Premium Support Forum

Login

The first step to access the support forum and open a topic is to login using the username and password created during the checkout process when purchasing GP Premium.

The Log In button can be found at the top of the support page beside the search bar:

Open Support Topic

Once you are logged in, you will see the Open Support Topic button beside the search bar:

The button takes you to the bottom of the page which shows you the general forum rules:

And pre-topic check list:

We would really appreciate if you can go through the two lists before opening a topic.

Private Information

Please keep in mind that this is a public forum so make sure to use the Private information field if you are going to provide info such as website URLs, login credentials, screenshots etc.

The info provided in the field is only visible to our customer support staff and is automatically removed once the topic is marked as resolved.

Forum Profile

The forum profile feature is often missed by our users.

It allows you to check the topics you have started:

Or change your forum display name so you can remain completely anonymous when posting topics:

Uploading Screenshots

Generally, our support staff can resolve issues most efficiently if you can provide the site URL in the Private information box so that we can view the issues and inspect the code.

If you need to upload screenshots for explanations, you can use a cloud service like Postimages or Imgur.

Profile Picture

The forum profile picture/Avatar can be uploaded using the Gravatar service.