In this blog tutorial, I will show you, how to create a simple Blog Website using WordPress using free version of GeneratePress theme. You can download the latest version of GeneratePress free theme from WordPress repository or from the GeneratePress website directly.
Home Page Gutenberg Blocks (GenerateBlocks)
1. First Post Block (Featured or Lead Post)
<!-- wp:generateblocks/container {"uniqueId":"dd19c67d","backgroundColor":"var(\u002d\u002dbase-2)","isDynamic":true,"blockVersion":4} -->
<!-- wp:generateblocks/container {"uniqueId":"b490e8e0","isDynamic":true,"blockVersion":4,"useGlobalMaxWidth":true,"spacing":{"marginRight":"auto","marginLeft":"auto","paddingTop":"20px","paddingBottom":"20px","paddingLeft":"20px","paddingRight":"20px"}} -->
<!-- wp:generateblocks/query-loop {"uniqueId":"5bd5bcba","query":{"post_type":"post","per_page":"1"}} -->
<!-- wp:generateblocks/grid {"uniqueId":"61d5c022","columns":1,"horizontalGap":20,"verticalGap":20,"isDynamic":true,"blockVersion":3,"isQueryLoop":true,"lock":{"remove":true}} -->
<!-- wp:generateblocks/container {"uniqueId":"5fdc7b0e","isGrid":true,"isQueryLoopItem":true,"gridId":"61d5c022","isDynamic":true,"blockVersion":4,"sizing":{"width":"100%","widthMobile":"100%"},"spacing":{"paddingTop":"20px","paddingRight":"20px","paddingBottom":"20px","paddingLeft":"20px","paddingTopMobile":"0px","paddingLeftMobile":"0px","paddingRightMobile":"0px","paddingBottomMobile":"0px"},"lock":{"remove":true,"move":true}} -->
<!-- wp:generateblocks/grid {"uniqueId":"ac29fcb9","columns":2,"horizontalGap":40,"verticalGap":20,"verticalAlignment":"center","isDynamic":true,"blockVersion":3} -->
<!-- wp:generateblocks/container {"uniqueId":"13be8e5d","isGrid":true,"gridId":"ac29fcb9","isDynamic":true,"blockVersion":4,"sizing":{"width":"50%","widthMobile":"100%"}} -->
<!-- wp:generateblocks/image {"uniqueId":"b022bc32","sizeSlug":"large","blockVersion":2,"spacing":{"marginBottom":"30px"},"borders":{"borderTopLeftRadius":"5px","borderTopRightRadius":"5px","borderBottomRightRadius":"5px","borderBottomLeftRadius":"5px"},"useDynamicData":true,"dynamicContentType":"featured-image","dynamicLinkType":"single-post"} /-->
<!-- /wp:generateblocks/container -->
<!-- wp:generateblocks/container {"uniqueId":"7c59d206","isGrid":true,"gridId":"ac29fcb9","isDynamic":true,"blockVersion":4,"sizing":{"width":"50%","widthMobile":"100%"}} -->
<!-- wp:generateblocks/headline {"uniqueId":"6f1f795f","element":"div","blockVersion":3,"typography":{"fontSize":"13px","lineHeight":"","fontWeight":"bold","textTransform":"uppercase","letterSpacing":"0.06em"},"spacing":{"marginBottom":"5px"},"linkColor":"var(\u002d\u002daccent)","linkColorHover":"var(\u002d\u002dcontrast)","useDynamicData":true,"dynamicContentType":"terms","dynamicLinkType":"term-archives","termTaxonomy":"category"} -->
<div class="gb-headline gb-headline-6f1f795f gb-headline-text"></div>
<!-- /wp:generateblocks/headline -->
<!-- wp:generateblocks/headline {"uniqueId":"ac83b54b","blockVersion":3,"typography":{"fontSize":"38px","fontWeight":"bold","fontSizeTablet":"30px","fontSizeMobile":"24px"},"spacing":{"marginBottom":"5px"},"linkColor":"var(\u002d\u002dcontrast)","linkColorHover":"var(\u002d\u002daccent)","useDynamicData":true,"dynamicContentType":"post-title","dynamicLinkType":"single-post"} -->
<h2 class="gb-headline gb-headline-ac83b54b gb-headline-text"></h2>
<!-- /wp:generateblocks/headline -->
<!-- wp:generateblocks/headline {"uniqueId":"2ca6507d","element":"p","blockVersion":3,"typography":{"fontSize":""},"spacing":{"marginBottom":"15px","marginTop":"15px"},"useDynamicData":true,"dynamicContentType":"post-excerpt","useDefaultMoreLink":false,"excerptLength":26} -->
<p class="gb-headline gb-headline-2ca6507d gb-headline-text"></p>
<!-- /wp:generateblocks/headline -->
<!-- wp:generateblocks/headline {"uniqueId":"08337bd5","element":"div","blockVersion":3,"display":"inline-flex","typography":{"fontSize":"15px"},"textColor":"var(\u002d\u002dcontrast-2)"} -->
<div class="gb-headline gb-headline-08337bd5 gb-headline-text">Written by: </div>
<!-- /wp:generateblocks/headline -->
<!-- wp:generateblocks/headline {"uniqueId":"2cd1cd3a","element":"p","blockVersion":3,"display":"inline-flex","alignItems":"flex-end","typography":{"fontSize":"15px","fontWeight":"bold"},"spacing":{"marginBottom":"0px","paddingRight":"","paddingTop":""},"textColor":"var(\u002d\u002dcontrast-2)","useDynamicData":true,"dynamicContentType":"author-name"} -->
<p class="gb-headline gb-headline-2cd1cd3a gb-headline-text"></p>
<!-- /wp:generateblocks/headline -->
<!-- wp:generateblocks/headline {"uniqueId":"d1eb1020","element":"div","blockVersion":3,"display":"flex","alignItems":"flex-end","typography":{"fontSize":"14px"},"spacing":{"marginBottom":"0px","marginRight":""},"textColor":"var(\u002d\u002dcontrast-2)","useDynamicData":true,"dynamicContentType":"post-date"} -->
<div class="gb-headline gb-headline-d1eb1020 gb-headline-text"></div>
<!-- /wp:generateblocks/headline -->
<!-- wp:generateblocks/button {"uniqueId":"480830f9","blockVersion":4,"display":"inline-flex","alignItems":"center","columnGap":"0.5em","spacing":{"paddingTop":"10px","paddingRight":"20px","paddingBottom":"10px","paddingLeft":"20px","marginTop":"25px"},"borders":{"borderTopWidth":"2px","borderTopStyle":"solid","borderRightWidth":"2px","borderRightStyle":"solid","borderBottomWidth":"2px","borderBottomStyle":"solid","borderLeftWidth":"2px","borderLeftStyle":"solid","borderTopColor":"var(\u002d\u002daccent)","borderTopColorHover":"var(\u002d\u002dcontrast-2)","borderRightColor":"var(\u002d\u002daccent)","borderBottomColor":"var(\u002d\u002daccent)","borderLeftColor":"var(\u002d\u002daccent)","borderLeftColorHover":"var(\u002d\u002dcontrast-2)","borderRightColorHover":"var(\u002d\u002dcontrast-2)","borderBottomColorHover":"var(\u002d\u002dcontrast-2)","borderTopLeftRadius":"5px","borderBottomRightRadius":"5px","borderTopRightRadius":"5px","borderBottomLeftRadius":"5px"},"textColor":"var(\u002d\u002daccent)","textColorHover":"var(\u002d\u002dcontrast-2)","gradientDirection":90,"gradientColorOne":"var(\u002d\u002daccent)","gradientColorTwo":"rgba(0, 0, 0, 0.30)","iconLocation":"right","iconPaddingRight":"","iconPaddingLeft":"0.5","iconStyles":{"height":"1.8em","width":"1.8em"},"useDynamicData":true,"dynamicLinkType":"single-post"} -->
<span class="gb-button gb-button-480830f9 gb-button-text">Read Article</span>
<!-- /wp:generateblocks/button -->
<!-- /wp:generateblocks/container -->
<!-- /wp:generateblocks/grid -->
<!-- /wp:generateblocks/container -->
<!-- /wp:generateblocks/grid -->
<!-- /wp:generateblocks/query-loop -->
<!-- /wp:generateblocks/container -->
<!-- /wp:generateblocks/container -->
2. Latest Post Block in Grid Format
<!-- wp:generateblocks/container {"uniqueId":"9366a1a5","isDynamic":true,"blockVersion":4} -->
<!-- wp:generateblocks/container {"uniqueId":"dcb56b32","isDynamic":true,"blockVersion":4,"useGlobalMaxWidth":true,"spacing":{"marginRight":"auto","marginLeft":"auto","paddingTop":"40px","paddingBottom":"40px","paddingLeft":"20px","paddingRight":"20px"}} -->
<!-- wp:generateblocks/query-loop {"uniqueId":"3058bb33","query":{"post_type":"post","per_page":"9","offset":"1"}} -->
<!-- wp:generateblocks/grid {"uniqueId":"ae47745b","columns":1,"horizontalGap":20,"verticalGap":20,"isDynamic":true,"blockVersion":3,"isQueryLoop":true,"lock":{"remove":true}} -->
<!-- wp:generateblocks/container {"uniqueId":"e7d1bb09","isGrid":true,"isQueryLoopItem":true,"gridId":"ae47745b","isDynamic":true,"blockVersion":4,"sizing":{"width":"33.33%","widthMobile":"100%","widthTablet":"50%"},"spacing":{"paddingTop":"20px","paddingRight":"20px","paddingBottom":"20px","paddingLeft":"20px","paddingTopMobile":"0px","paddingLeftMobile":"0px","paddingRightMobile":"0px","paddingBottomMobile":"0px"},"lock":{"remove":true,"move":true}} -->
<!-- wp:generateblocks/image {"uniqueId":"bc4f91ad","sizeSlug":"large","blockVersion":2,"spacing":{"marginBottom":"30px"},"borders":{"borderTopLeftRadius":"5px","borderTopRightRadius":"5px","borderBottomRightRadius":"5px","borderBottomLeftRadius":"5px"},"useDynamicData":true,"dynamicContentType":"featured-image","dynamicLinkType":"single-post"} /-->
<!-- wp:generateblocks/headline {"uniqueId":"8f8c6158","element":"div","blockVersion":3,"typography":{"fontSize":"13px","lineHeight":"","fontWeight":"bold","textTransform":"uppercase","letterSpacing":"0.06em"},"spacing":{"marginBottom":"5px"},"linkColor":"var(\u002d\u002daccent)","linkColorHover":"var(\u002d\u002dcontrast)","useDynamicData":true,"dynamicContentType":"terms","dynamicLinkType":"term-archives","termTaxonomy":"category"} -->
<div class="gb-headline gb-headline-8f8c6158 gb-headline-text"></div>
<!-- /wp:generateblocks/headline -->
<!-- wp:generateblocks/headline {"uniqueId":"c7a6a5fe","blockVersion":3,"typography":{"fontSize":"23px","lineHeight":"1.5em","fontWeight":"bold","fontSizeTablet":"20px","fontSizeMobile":"18px"},"spacing":{"marginBottom":"5px"},"linkColor":"var(\u002d\u002dcontrast)","linkColorHover":"var(\u002d\u002daccent)","useDynamicData":true,"dynamicContentType":"post-title","dynamicLinkType":"single-post"} -->
<h2 class="gb-headline gb-headline-c7a6a5fe gb-headline-text"></h2>
<!-- /wp:generateblocks/headline -->
<!-- wp:generateblocks/headline {"uniqueId":"8bb8d87b","element":"div","blockVersion":3,"display":"inline-flex","typography":{"fontSize":"15px"},"textColor":"var(\u002d\u002dcontrast-2)"} -->
<div class="gb-headline gb-headline-8bb8d87b gb-headline-text">Written by: </div>
<!-- /wp:generateblocks/headline -->
<!-- wp:generateblocks/headline {"uniqueId":"f29f2c81","element":"div","blockVersion":3,"display":"inline-flex","alignItems":"flex-end","typography":{"fontSize":"15px","fontWeight":"bold"},"spacing":{"marginBottom":"0px","paddingRight":"10px"},"textColor":"var(\u002d\u002dcontrast-2)","useDynamicData":true,"dynamicContentType":"author-name"} -->
<div class="gb-headline gb-headline-f29f2c81 gb-headline-text"></div>
<!-- /wp:generateblocks/headline -->
<!-- wp:generateblocks/headline {"uniqueId":"13ca27e8","element":"div","blockVersion":3,"typography":{"fontSize":"14px"},"spacing":{"marginBottom":"0px"},"textColor":"var(\u002d\u002dcontrast-2)","useDynamicData":true,"dynamicContentType":"post-date"} -->
<div class="gb-headline gb-headline-13ca27e8 gb-headline-text"></div>
<!-- /wp:generateblocks/headline -->
<!-- /wp:generateblocks/container -->
<!-- /wp:generateblocks/grid -->
<!-- /wp:generateblocks/query-loop -->
<!-- wp:generateblocks/container {"uniqueId":"34ff37b7","isDynamic":true,"blockVersion":4,"typography":{"textAlign":"center"}} -->
<!-- wp:generateblocks/button {"uniqueId":"43c91a80","hasUrl":true,"blockVersion":4,"display":"inline-flex","alignItems":"center","columnGap":"0.5em","spacing":{"paddingTop":"10px","paddingRight":"20px","paddingBottom":"10px","paddingLeft":"20px","marginTop":"15px"},"borders":{"borderTopWidth":"2px","borderTopStyle":"solid","borderRightWidth":"2px","borderRightStyle":"solid","borderBottomWidth":"2px","borderBottomStyle":"solid","borderLeftWidth":"2px","borderLeftStyle":"solid","borderTopColor":"var(\u002d\u002daccent)","borderTopColorHover":"var(\u002d\u002dcontrast-3)","borderRightColor":"var(\u002d\u002daccent)","borderBottomColor":"var(\u002d\u002daccent)","borderLeftColor":"var(\u002d\u002daccent)","borderLeftColorHover":"var(\u002d\u002dcontrast-3)","borderRightColorHover":"var(\u002d\u002dcontrast-3)","borderBottomColorHover":"var(\u002d\u002dcontrast-3)","borderTopLeftRadius":"5px","borderBottomRightRadius":"5px","borderTopRightRadius":"5px","borderBottomLeftRadius":"5px"},"textColor":"var(\u002d\u002daccent)","textColorHover":"var(\u002d\u002dcontrast-3)","gradientDirection":90,"gradientColorOne":"var(\u002d\u002daccent)","gradientColorTwo":"rgba(0, 0, 0, 0.30)","iconLocation":"right","iconPaddingRight":"","iconPaddingLeft":"0.5","iconStyles":{"height":"1.8em","width":"1.8em"},"dynamicLinkType":"single-post"} -->
<a class="gb-button gb-button-43c91a80 gb-button-text" href="http://localhost/webdev/blog/">Read All Article</a>
<!-- /wp:generateblocks/button -->
<!-- /wp:generateblocks/container -->
<!-- /wp:generateblocks/container -->
<!-- /wp:generateblocks/container -->
Custom CSS Code
.main-navigation .main-nav ul li a {
line-height: 45px;
}
.gp-custom-category-section {
margin-bottom: 10px;
font-size: 14px;
letter-spacing: 0.5px;
}
.read-more-section {
text-align: center;
}
.read-more-section .custom-readmore-button {
border: 1px solid var(--accent);
padding: 12px;
}
.read-more-section .custom-readmore-button:hover {
background: var(--accent);
color: var(--base-3);
}
.entry-meta {
margin-bottom: 25px;
}
.tags-links {
margin-bottom: 15px;
}
PHP Code Snippets
Site Customization Code
add_action( 'generate_after_entry_header','wpf_gp_custom_thumbnail_image' );
if( !function_exists('wpf_gp_custom_thumbnail_image')) {
function wpf_gp_custom_thumbnail_image() {
if(is_single()) {
$feat_image = wp_get_attachment_url( get_post_thumbnail_id(get_the_ID()) );
echo '<img class="single-featured-image" src="'.$feat_image.'"></img>';
}
}
}
add_action( 'generate_before_entry_title','wpf_gp_custom_before_title' );
if( !function_exists('wpf_gp_custom_before_title')) {
function wpf_gp_custom_before_title() {
$post_categories = wp_get_post_categories(get_the_ID(), [ 'fields' => 'all' ]);
$category_content = '<div class="gp-custom-category-section">';
if( $post_categories ) {
foreach($post_categories as $c) {
$category_link = get_category_link( $c->term_id );
$category_content = $category_content . '<a href="'. $category_link .'">' . $c->name . '</a>' . ' / ';
}
$category_content = rtrim($category_content, ' / ');
}
$category_content = $category_content . '</div>';
echo $category_content;
}
}
add_filter( 'generate_post_date_output','wpf_gp_custom_add_to_post_date' );
if( !function_exists('wpf_gp_custom_add_to_post_date')) {
function wpf_gp_custom_add_to_post_date( $output ) {
return '<div class="gp-post-date-author">' . $output;
}
}
add_filter( 'generate_post_author_output','wpf_gp_custom_add_to_post_author' );
if( !function_exists('wpf_gp_custom_add_to_post_author')) {
function wpf_gp_custom_add_to_post_author( $output ) {
return $output . '</div>';
}
}
add_filter( 'generate_leave_comment','wpf_gp_custom_remove_comment_link' );
if( !function_exists('wpf_gp_custom_remove_comment_link')) {
function wpf_gp_custom_remove_comment_link() {
return false;
}
}
add_filter( 'generate_show_comments', '__return_false' );
add_filter( 'generate_show_categories', '__return_false' );
add_filter( 'generate_excerpt_more_output', 'wpf_gp_custom_read_more' );
if( !function_exists('wpf_gp_custom_read_more')) {
function wpf_gp_custom_read_more() {
return '<div class="read-more-section"><a class="custom-readmore-button" href="'.get_permalink(get_the_ID()).'">Continue Reading →</a></div>';
}
}
add_action( 'after_setup_theme','wpf_gp_remove_featured_image' );
if( !function_exists('wpf_gp_remove_featured_image')) {
function wpf_gp_remove_featured_image() {
remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single', 10 );
}
}
GeneratePress Custom Copyright Text
add_filter( 'generate_copyright','nahidislam_gp_custom_copyright' );
if (!function_exists('nahidislam_gp_custom_copyright')) {
function nahidislam_gp_custom_copyright() {
$year = date("Y");
?>
© <?php echo $year ?> WordPress Site Development• All Rights Reserved!
<?php
}
}