Skip to content

Commit

Permalink
Fix search results and post meta
Browse files Browse the repository at this point in the history
  • Loading branch information
khleomix committed Jul 3, 2024
1 parent dd0209c commit 278c45b
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 40 deletions.
21 changes: 21 additions & 0 deletions patterns/post-meta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* Title: Post Meta
* Slug: wdsbt/post-meta
* Categories: content
* Block Types: custom/post-meta
*
* @package wdsbt
*/

// Check if modified date is same as current date.
$wds_post_date = get_the_date( 'U' ) !== get_the_modified_date( 'U' ) ? '<!-- wp:paragraph --><p>Posted On:</p><!-- /wp:paragraph --><!-- wp:post-date {"format":"M j, Y"} /--> <!-- wp:paragraph --><p>Last Updated:</p><!-- /wp:paragraph --><!-- wp:post-date {"format":"M j, Y","displayType":"modified"} /-->' : '<!-- wp:paragraph --><p>Posted On:</p><!-- /wp:paragraph --><!-- wp:post-date {"format":"M j, Y"} /-->';

?>

<!-- wp:group {"metadata":{"name":"Post Meta"},"className":"post-meta","style":{"spacing":{"blockGap":"0"}},"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group post-meta">
<?php echo wp_kses_post( $wds_post_date ); ?>
</div>
<!-- /wp:group -->

44 changes: 44 additions & 0 deletions patterns/search-results.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Title: Search Results
* Slug: wdsbt/search-results
* Categories: search
* Template Types: search
* Block Types: custom/search-results
* Inserter: false
*
* @package wdsbt
*/

?>
<!-- wp:query {"queryId":0,"query":{"perPage":10,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":true}} -->
<div class="wp-block-query">
<!-- wp:post-template {"layout":{"type":"default","columnCount":3}} -->
<!-- wp:post-title {"isLink":true} /-->

<!-- wp:pattern {"slug":"wdsbt/post-meta"} /-->

<!-- wp:post-excerpt {"moreText":"Read More"} /-->

<!-- wp:separator {"className":"is-style-wide"} -->
<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>
<!-- /wp:separator -->
<!-- /wp:post-template -->

<!-- wp:query-pagination -->
<!-- wp:query-pagination-previous /-->
<!-- wp:query-pagination-numbers /-->
<!-- wp:query-pagination-next /-->
<!-- /wp:query-pagination -->

<!-- wp:query-no-results -->
<!-- wp:paragraph {"placeholder":"Add text or blocks that will display when a query returns no results."} -->
<p>Hmmm... We didn't find anything for your search query.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Double check your search for any typos or spelling error or try a different search term.</p>
<!-- /wp:paragraph -->
<!-- /wp:query-no-results -->
</div>
<!-- /wp:query -->
41 changes: 1 addition & 40 deletions templates/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,7 @@

<!-- wp:query-title {"type":"search"} /-->

<!-- wp:query {"queryId":0,"query":{"perPage":10,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":true}} -->
<div class="wp-block-query">
<!-- wp:post-template {"layout":{"type":"default","columnCount":3}} -->
<!-- wp:post-title {"isLink":true} /-->

<!-- wp:group {"className":"post-meta","layout":{"type":"flex","flexWrap":"wrap"},"metadata":{"name":"Post Meta"}} -->
<div class="wp-block-group post-meta">
<!-- wp:paragraph -->
<p>Posted Date: <!-- wp:post-date /--></p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>Last Updated: <!-- wp:post-date {"displayType":"modified"} /--></p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:group -->

<!-- wp:post-excerpt {"moreText":"Read More"} /-->

<!-- wp:separator {"className":"is-style-wide"} -->
<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>
<!-- /wp:separator -->
<!-- /wp:post-template -->

<!-- wp:query-pagination -->
<!-- wp:query-pagination-previous /-->
<!-- wp:query-pagination-numbers /-->
<!-- wp:query-pagination-next /-->
<!-- /wp:query-pagination -->

<!-- wp:query-no-results -->
<!-- wp:paragraph {"placeholder":"Add text or blocks that will display when a query returns no results."} -->
<p>Hmmm... We didn't find anything for your search query.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Double check your search for any typos or spelling error or try a different search term.</p>
<!-- /wp:paragraph -->
<!-- /wp:query-no-results -->
</div>
<!-- /wp:query -->
<!-- wp:pattern {"slug":"wdsbt/search-results"} /-->

</main>
<!-- /wp:group -->
Expand Down

0 comments on commit 278c45b

Please sign in to comment.