add related posts section to single post template
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Aadil Ayub 2024-07-03 12:53:43 +05:00
parent 5da0ab78a3
commit 88e11704a0
2 changed files with 161 additions and 75 deletions

View File

@ -152,4 +152,20 @@ function cc_mime_types($mimes) {
}
add_filter('upload_mimes', 'cc_mime_types');
// enable wordpress customizer
// remove current post from related posts query loop
add_filter( 'query_loop_block_query_vars', function( $query_vars, $block ) {
if ( isset( $block->attributes['metadata']['name'] ) && $block->attributes['metadata']['name'] === 'Related Post' ) {
$query_vars['post__not_in'] = array( get_the_ID() );
}
return $query_vars;
}, 10, 2 );
function jett_remove_current_from_queries( $query_vars, $block ) {
do_action( 'qm/debug', $block->parsed_block );
if ( 'related-post' === $block->parsed_block['attrs']['className'] )
$query_vars['post__not_in'] = array( get_the_ID() );
return $query_vars;
}
add_filter( 'query_loop_block_query_vars', 'jett_remove_current_from_queries', 10, 2 );

View File

@ -1,84 +1,154 @@
<!-- wp:template-part {"slug":"header","area":"header"} /-->
<!-- wp:columns {"style":{"spacing":{"blockGap":{"top":"0","left":"0"},"margin":{"top":"0","bottom":"0"}}}} -->
<div class="wp-block-columns" style="margin-top:0;margin-bottom:0"><!-- wp:column {"width":"19.05%"} -->
<div class="wp-block-column" style="flex-basis:19.05%"></div>
<!-- /wp:column -->
<!-- wp:column {"width":"","style":{"border":{"left":{"width":"0px","style":"none"},"top":[],"right":[],"bottom":[]}}} -->
<div class="wp-block-column" style="border-left-style:none;border-left-width:0px">
<!-- wp:group {"metadata":{"name":"Header"},"style":{"spacing":{"blockGap":"0","padding":{"bottom":"0"},"margin":{"bottom":"0"}},"border":{"bottom":{"color":"var:preset|color|black","width":"16px"},"top":{"width":"0px","style":"none"},"right":{"color":"var:preset|color|black","width":"1px"},"left":{"color":"var:preset|color|black","width":"1px"}}},"className":"post-header","layout":{"type":"default"}} -->
<div class="wp-block-group post-header"
style="border-top-style:none;border-top-width:0px;border-right-color:var(--wp--preset--color--black);border-right-width:1px;border-bottom-color:var(--wp--preset--color--black);border-bottom-width:16px;border-left-color:var(--wp--preset--color--black);border-left-width:1px;margin-bottom:0;padding-bottom:0">
<!-- wp:post-featured-image {"width":"","style":{"border":{"radius":"0px","bottom":{"width":"1px"},"top":[],"right":[],"left":[]}},"className":"pcss-fd148ecc","pcssAdditionalCss":"[block] img {\n aspect-ratio: 73 / 35;\n}","pcssAdditionalCssCompiled":".pcss-fd148ecc img{aspect-ratio:73/35}","pcssClassId":"pcss-fd148ecc"} /-->
<!-- wp:group {"metadata":{"name":"Post Meta"},"style":{"spacing":{"padding":{"right":"var:preset|spacing|50","left":"var:preset|spacing|50","top":"var:preset|spacing|40","bottom":"var:preset|spacing|40"}}},"layout":{"type":"default"}} -->
<div class="wp-block-group"
style="padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--50);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--50)">
<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group">
<!-- wp:post-date {"style":{"typography":{"fontStyle":"normal","fontWeight":"500"}}} /-->
<!-- wp:post-author-name {"style":{"typography":{"fontStyle":"normal","fontWeight":"500"}},"fontFamily":"commit-mono"} /-->
</div>
<!-- /wp:group -->
<!-- wp:post-title /-->
<!-- wp:post-excerpt /-->
<!-- wp:post-terms {"term":"post_tag","separator":"","className":"is-style-hashtags"} /-->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:group -->
<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|50","bottom":"var:preset|spacing|50","left":"0","right":"0"},"margin":{"top":"0"}},"border":{"bottom":{"width":"16px"},"top":{"width":"0px","style":"none"},"right":{"width":"1px"},"left":{"width":"1px"}}},"className":"post-content-container","layout":{"type":"constrained","justifyContent":"left","contentSize":"640px","wideSize":""},"fontSize":"standard"} -->
<div class="wp-block-group post-content-container has-standard-font-size"
style="border-top-style:none;border-top-width:0px;border-right-width:1px;border-bottom-width:16px;border-left-width:1px;margin-top:0;padding-top:var(--wp--preset--spacing--50);padding-right:0;padding-bottom:var(--wp--preset--spacing--50);padding-left:0">
<!-- wp:group {"style":{"spacing":{"padding":{"right":"var:preset|spacing|70","left":"var:preset|spacing|70"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group"
style="padding-right:var(--wp--preset--spacing--70);padding-left:var(--wp--preset--spacing--70)">
<!-- wp:post-content {"style":{"typography":{"fontSize":"20px","lineHeight":"1.6"},"spacing":{"padding":{"top":"var:preset|spacing|40"}}},"className":"blog-post-content","fontFamily":"roboto-serif"} /-->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:group -->
<!-- wp:group {"metadata":{"name":"post-bio-container"},"style":{"elements":{"link":{"color":{"text":"var:preset|color|white"}}},"spacing":{"padding":{"top":"var:preset|spacing|70","bottom":"var:preset|spacing|70","left":"var:preset|spacing|70","right":"var:preset|spacing|70"}}},"backgroundColor":"black","textColor":"white","className":"post-bio-container","layout":{"type":"constrained","contentSize":"640px","wideSize":"1480px"}} -->
<div
class="wp-block-group post-bio-container has-white-color has-black-background-color has-text-color has-background has-link-color"
style="padding-top:var(--wp--preset--spacing--70);padding-right:var(--wp--preset--spacing--70);padding-bottom:var(--wp--preset--spacing--70);padding-left:var(--wp--preset--spacing--70)">
<!-- wp:heading {"textAlign":"center","style":{"elements":{"link":{"color":{"text":"var:preset|color|white"}}}},"textColor":"white","fontSize":"x-large"} -->
<h2
class="wp-block-heading has-text-align-center has-white-color has-text-color has-link-color has-x-large-font-size">
About the authors</h2>
<!-- /wp:heading -->
<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column {"width":"29%"} -->
<div class="wp-block-column" style="flex-basis:29%"><!-- wp:co-authors-plus/coauthors {"prefix":""} -->
<div class="wp-block-co-authors-plus-coauthors">
<!-- wp:co-authors-plus/name {"style":{"typography":{"fontStyle":"normal","fontWeight":"700"}},"fontSize":"standard"} /-->
</div>
<!-- /wp:co-authors-plus/coauthors -->
</div>
<div class="wp-block-column" style="flex-basis:19.05%"></div>
<!-- /wp:column -->
<!-- wp:column {"width":"66.66%"} -->
<div class="wp-block-column" style="flex-basis:66.66%">
<!-- wp:co-authors-plus/coauthors {"prefix":"","separator":"","lastSeparator":"","className":"pcss-54b4243c","pcssAdditionalCss":"[block] .wp-block-co-authors-plus-coauthor {\n margin-bottom: 2em;\n display: block !important;\n}","pcssAdditionalCssCompiled":".pcss-54b4243c .wp-block-co-authors-plus-coauthor{margin-bottom:2em;display:block!important}","pcssClassId":"pcss-54b4243c"} -->
<div class="wp-block-co-authors-plus-coauthors pcss-54b4243c">
<!-- wp:co-authors-plus/description {"style":{"typography":{"lineHeight":"1.6"}},"className":"pcss-f9607632","fontSize":"small","fontFamily":"roboto-serif","pcssAdditionalCss":"[block] {\n}","pcssClassId":"pcss-f9607632"} /-->
</div>
<!-- /wp:co-authors-plus/coauthors -->
<!-- wp:column {"width":"","style":{"border":{"left":{"width":"0px","style":"none"},"top":[],"right":[],"bottom":[]}}} -->
<div class="wp-block-column" style="border-left-style:none;border-left-width:0px">
<!-- wp:group {"metadata":{"name":"Header"},"style":{"spacing":{"blockGap":"0","padding":{"bottom":"0"},"margin":{"bottom":"0"}},"border":{"bottom":{"color":"var:preset|color|black","width":"16px"},"top":{"width":"0px","style":"none"},"right":{"color":"var:preset|color|black","width":"1px"},"left":{"color":"var:preset|color|black","width":"1px"}}},"className":"post-header","layout":{"type":"default"}} -->
<div class="wp-block-group post-header"
style="border-top-style:none;border-top-width:0px;border-right-color:var(--wp--preset--color--black);border-right-width:1px;border-bottom-color:var(--wp--preset--color--black);border-bottom-width:16px;border-left-color:var(--wp--preset--color--black);border-left-width:1px;margin-bottom:0;padding-bottom:0">
<!-- wp:post-featured-image {"width":"","style":{"border":{"radius":"0px","bottom":{"width":"1px"},"top":[],"right":[],"left":[]}},"className":"pcss-fd148ecc","pcssAdditionalCss":"[block] img {\n aspect-ratio: 73 / 35;\n}","pcssAdditionalCssCompiled":".pcss-fd148ecc img{aspect-ratio:73/35}","pcssClassId":"pcss-fd148ecc"} /-->
<!-- wp:group {"metadata":{"name":"Post Meta"},"style":{"spacing":{"padding":{"right":"var:preset|spacing|50","left":"var:preset|spacing|50","top":"var:preset|spacing|40","bottom":"var:preset|spacing|40"}}},"layout":{"type":"default"}} -->
<div class="wp-block-group"
style="padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--50);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--50)">
<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group">
<!-- wp:post-date {"style":{"typography":{"fontStyle":"normal","fontWeight":"500"}}} /-->
<!-- wp:post-author-name {"style":{"typography":{"fontStyle":"normal","fontWeight":"500"}},"fontFamily":"commit-mono"} /-->
</div>
<!-- /wp:group -->
<!-- wp:post-title /-->
<!-- wp:post-excerpt /-->
<!-- wp:post-terms {"term":"post_tag","separator":"","className":"is-style-hashtags"} /-->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:group -->
<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|50","bottom":"var:preset|spacing|50","left":"0","right":"0"},"margin":{"top":"0"}},"border":{"bottom":{"width":"16px"},"top":{"width":"0px","style":"none"},"right":{"width":"1px"},"left":{"width":"1px"}}},"className":"post-content-container","layout":{"type":"constrained","justifyContent":"left","contentSize":"640px","wideSize":""},"fontSize":"standard"} -->
<div class="wp-block-group post-content-container has-standard-font-size"
style="border-top-style:none;border-top-width:0px;border-right-width:1px;border-bottom-width:16px;border-left-width:1px;margin-top:0;padding-top:var(--wp--preset--spacing--50);padding-right:0;padding-bottom:var(--wp--preset--spacing--50);padding-left:0">
<!-- wp:group {"style":{"spacing":{"padding":{"right":"var:preset|spacing|70","left":"var:preset|spacing|70"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group"
style="padding-right:var(--wp--preset--spacing--70);padding-left:var(--wp--preset--spacing--70)">
<!-- wp:post-content {"style":{"typography":{"fontSize":"20px","lineHeight":"1.6"},"spacing":{"padding":{"top":"var:preset|spacing|40"}}},"className":"blog-post-content","fontFamily":"roboto-serif"} /-->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:group -->
<!-- wp:group {"metadata":{"name":"post-bio-container"},"style":{"elements":{"link":{"color":{"text":"var:preset|color|white"}}},"spacing":{"padding":{"top":"var:preset|spacing|70","bottom":"var:preset|spacing|70","left":"var:preset|spacing|70","right":"var:preset|spacing|70"}}},"backgroundColor":"black","textColor":"white","className":"post-bio-container","layout":{"type":"constrained","contentSize":"640px","wideSize":"1480px"}} -->
<div class="wp-block-group post-bio-container has-white-color has-black-background-color has-text-color has-background has-link-color"
style="padding-top:var(--wp--preset--spacing--70);padding-right:var(--wp--preset--spacing--70);padding-bottom:var(--wp--preset--spacing--70);padding-left:var(--wp--preset--spacing--70)">
<!-- wp:heading {"textAlign":"center","style":{"elements":{"link":{"color":{"text":"var:preset|color|white"}}}},"textColor":"white","fontSize":"x-large"} -->
<h2
class="wp-block-heading has-text-align-center has-white-color has-text-color has-link-color has-x-large-font-size">
About the authors</h2>
<!-- /wp:heading -->
<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column {"width":"29%"} -->
<div class="wp-block-column" style="flex-basis:29%">
<!-- wp:co-authors-plus/coauthors {"prefix":""} -->
<div class="wp-block-co-authors-plus-coauthors">
<!-- wp:co-authors-plus/name {"style":{"typography":{"fontStyle":"normal","fontWeight":"700"}},"fontSize":"standard"} /-->
</div>
<!-- /wp:co-authors-plus/coauthors -->
</div>
<!-- /wp:column -->
<!-- wp:column {"width":"66.66%"} -->
<div class="wp-block-column" style="flex-basis:66.66%">
<!-- wp:co-authors-plus/coauthors {"prefix":"","separator":"","lastSeparator":"","className":"pcss-54b4243c","pcssAdditionalCss":"[block] .wp-block-co-authors-plus-coauthor {\n margin-bottom: 2em;\n display: block !important;\n}","pcssAdditionalCssCompiled":".pcss-54b4243c .wp-block-co-authors-plus-coauthor{margin-bottom:2em;display:block!important}","pcssClassId":"pcss-54b4243c"} -->
<div class="wp-block-co-authors-plus-coauthors pcss-54b4243c">
<!-- wp:co-authors-plus/description {"style":{"typography":{"lineHeight":"1.6"}},"className":"pcss-f9607632","fontSize":"small","fontFamily":"roboto-serif","pcssAdditionalCss":"[block] {\n}","pcssClassId":"pcss-f9607632"} /-->
</div>
<!-- /wp:co-authors-plus/coauthors -->
</div>
<!-- /wp:column -->
</div>
<!-- /wp:columns -->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:column -->
</div>
<!-- /wp:columns -->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:column -->
</div>
<!-- /wp:columns -->
<!-- wp:spacer {"height":"129px"} -->
<div style="height:129px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->
<!-- wp:group {"metadata":{"name":"Related Posts"},"align":"full","style":{"spacing":{"margin":{"top":"0","bottom":"0"}}},"layout":{"type":"default"}} -->
<div class="wp-block-group alignfull" style="margin-top:0;margin-bottom:0">
<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|30","bottom":"var:preset|spacing|30"},"margin":{"top":"0","bottom":"0"}}},"backgroundColor":"black","layout":{"type":"default"}} -->
<div class="wp-block-group has-black-background-color has-background"
style="margin-top:0;margin-bottom:0;padding-top:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--30)">
<!-- wp:heading {"textAlign":"center","style":{"typography":{"fontStyle":"normal","fontWeight":"600"}},"className":"is-style-gradient","fontSize":"xx-large","fontFamily":"instrument-sans"} -->
<h2 class="wp-block-heading has-text-align-center is-style-gradient has-instrument-sans-font-family has-xx-large-font-size"
style="font-style:normal;font-weight:600">From The Blog</h2>
<!-- /wp:heading -->
</div>
<!-- /wp:group -->
<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|70","bottom":"var:preset|spacing|50","left":"var:preset|spacing|80","right":"var:preset|spacing|80"}}},"layout":{"type":"default"}} -->
<div class="wp-block-group"
style="padding-top:var(--wp--preset--spacing--70);padding-right:var(--wp--preset--spacing--80);padding-bottom:var(--wp--preset--spacing--50);padding-left:var(--wp--preset--spacing--80)">
<!-- wp:query {"queryId":13,"query":{"perPage":"6","pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"metadata":{"name":"Normal posts"},"className":"home-posts-grid","layout":{"type":"default"}} -->
<div class="wp-block-query home-posts-grid">
<!-- wp:post-template {"metadata":{"name":"Related Post"},"align":"full","style":{"spacing":{"blockGap":"var:preset|spacing|70"}},"className":"related-posts","layout":{"type":"grid","columnCount":"2","minimumColumnWidth":null}} -->
<!-- wp:columns {"style":{"border":{"top":{"width":"1px","color":"var:preset|color|black"},"right":{"width":"1px","color":"var:preset|color|black"},"bottom":{"width":"16px","color":"var:preset|color|black"},"left":{"width":"1px","color":"var:preset|color|black"}},"spacing":{"blockGap":{"top":"0","left":"0"}}},"className":"home-post-item"} -->
<div class="wp-block-columns home-post-item"
style="border-top-color:var(--wp--preset--color--black);border-top-width:1px;border-right-color:var(--wp--preset--color--black);border-right-width:1px;border-bottom-color:var(--wp--preset--color--black);border-bottom-width:16px;border-left-color:var(--wp--preset--color--black);border-left-width:1px">
<!-- wp:column {"width":"30%"} -->
<div class="wp-block-column" style="flex-basis:30%">
<!-- wp:post-featured-image {"width":"","height":"100%","sizeSlug":"full","style":{"layout":{"selfStretch":"fit","flexSize":null},"border":{"right":{"width":"1px"}}},"className":"home-post-item-img"} /-->
</div>
<!-- /wp:column -->
<!-- wp:column {"width":"","style":{"spacing":{"padding":{"right":"var:preset|spacing|60","left":"var:preset|spacing|60","top":"var:preset|spacing|30","bottom":"var:preset|spacing|30"}}}} -->
<div class="wp-block-column"
style="padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--60);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--60)">
<!-- wp:post-date {"format":"M.j.y","style":{"typography":{"fontStyle":"normal","fontWeight":"700"},"spacing":{"padding":{"top":"var:preset|spacing|30"}}},"fontSize":"small","fontFamily":"commit-mono"} /-->
<!-- wp:post-title {"isLink":true,"className":"post-title"} /-->
<!-- wp:post-excerpt {"style":{"typography":{"fontStyle":"normal","fontWeight":"500"}},"fontFamily":"commit-mono"} /-->
<!-- wp:post-terms {"term":"post_tag","separator":"","className":"is-style-hashtags"} /-->
</div>
<!-- /wp:column -->
</div>
<!-- /wp:columns -->
<!-- /wp:post-template -->
</div>
<!-- /wp:query -->
</div>
<!-- /wp:group -->
<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|50","bottom":"var:preset|spacing|60"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group"
style="padding-top:var(--wp--preset--spacing--50);padding-bottom:var(--wp--preset--spacing--60)">
<!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center","verticalAlignment":"stretch"}} -->
<div class="wp-block-buttons">
<!-- wp:button {"style":{"spacing":{"padding":{"left":"0","right":"0"}}},"className":"pcss-808b88d9","fontSize":"medium","pcssAdditionalCss":"[block] {\n width: 100%;\n margin-inline: 1rem !important;\n display: inline-block;\n transition: 0.25s ease-in-out;\n}\n\n[block] .wp-element-button {\n width: 100%;\n}\n\n[block]:hover {\n box-shadow: rgb(51, 51, 51) 4px 4px 0 0;\n transform: translate(-4px, -4px)\n}","pcssAdditionalCssCompiled":".pcss-808b88d9{width:100%;transition:all .25s ease-in-out;display:inline-block;margin-inline:1rem!important}.pcss-808b88d9 .wp-element-button{width:100%}.pcss-808b88d9:hover{transform:translate(-4px,-4px);box-shadow:4px 4px #333}","pcssClassId":"pcss-808b88d9"} -->
<div class="wp-block-button has-custom-font-size pcss-808b88d9 has-medium-font-size"><a
class="wp-block-button__link wp-element-button" href="https://jett.local/blog/"
style="padding-right:0;padding-left:0">More ➔</a></div>
<!-- /wp:button -->
</div>
<!-- /wp:buttons -->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:group -->
<!-- wp:template-part {"slug":"footer","area":"footer"} /-->