diff --git a/web/app/themes/awasqa/functions.php b/web/app/themes/awasqa/functions.php index 364a3d1..06380b9 100644 --- a/web/app/themes/awasqa/functions.php +++ b/web/app/themes/awasqa/functions.php @@ -149,6 +149,18 @@ function awasqa_carbon_get_post_meta($post_id, $name, $container_id = '') Field::make('text', 'source_url', 'Source URL')->set_attribute('type', 'url'), )); + Container::make('post_meta', 'Related Posts') + ->where('post_type', '=', 'post') + ->add_fields(array( + Field::make('association', 'related_posts', 'Posts') + ->set_types([ + [ + 'type' => 'post', + 'post_type' => 'post' + ] + ]) + )); + Container::make('post_meta', 'Contact') ->where('post_type', '=', 'awasqa_organisation') ->add_fields(array( @@ -431,38 +443,6 @@ function get_issue_options() set_icon('networking') - ->add_fields(array( - Field::make('separator', 'crb_separator', __('Organisations Column')) - )) - ->set_render_callback(function ($fields, $attributes, $inner_blocks) { - $post = get_post(); - $authors = get_coauthors($post->ID); - if (!$authors) { - return; - } - $orgs_data = []; - foreach ($authors as $author) { - $orgs = get_author_organisations($author->ID); - foreach ($orgs as $org) { - $orgs_data[] = [ - - ]; - } - } - ?> -
-
- -
- set_icon('admin-users') ->add_fields(array( @@ -594,6 +574,20 @@ function get_issue_options() $query['author'] = $author->ID; } } + // Display related posts on single post page + if (($query['s'] ?? '') === ':related') { + $query['s'] = ''; + $post_ids = []; + $related_posts = awasqa_carbon_get_post_meta($post->ID, 'related_posts') ?? []; + foreach ($related_posts as $related_post) { + $post_ids[] = $related_post['id']; + } + if (!$post_ids) { + $post_ids = [0]; + } + $query['post__in'] = $post_ids; + $query['ignore_sticky_posts'] = 1; + } return $query; }); diff --git a/web/app/themes/awasqa/script.js b/web/app/themes/awasqa/script.js index ce6f2e9..7ce754f 100644 --- a/web/app/themes/awasqa/script.js +++ b/web/app/themes/awasqa/script.js @@ -23,5 +23,12 @@ document.querySelectorAll(".wp-block-post-date").forEach(block => { block.innerText = (new Date(datetime)).toLocaleDateString(LOCALE, { month: "short", day: "numeric", year: "numeric" }) }) +document.querySelectorAll('.awasqa-related-posts').forEach(block => { + const posts = block.querySelectorAll('.wp-block-post') + if (!posts.length) { + block.style.display = 'none' + } +}) + // Display content (hidden by pre-script.js) document.body.style.visibility = "visible" diff --git a/web/app/themes/awasqa/style.css b/web/app/themes/awasqa/style.css index 5c74904..527ab17 100644 --- a/web/app/themes/awasqa/style.css +++ b/web/app/themes/awasqa/style.css @@ -176,6 +176,12 @@ h6::after { .awasqa-authors-column { margin-bottom: 5.625rem; } +.awasqa-authors-column h6 { + margin-top: 0; + } +.awasqa-authors-column .awasqa-author-column { + margin-bottom: var(--wp--style--block-gap); + } .awasqa-authors { display: flex; list-style: none; @@ -207,17 +213,13 @@ h6::after { footer .wp-block-image img { vertical-align: middle; } -/* Prevent gap between single post background color and footer */ -.single-post footer { - margin-top: 0; - } -.awasqa-heading-link { +.awasqa-heading-link a { align-items: center; color: var(--color-green-lighter); display: inline-flex; text-decoration: none; } -.awasqa-heading-link::after { +.awasqa-heading-link a::after { content: ""; background-image: url("/app/themes/awasqa/assets/images/arrow-right-lighter.svg"); background-position: center; @@ -226,7 +228,7 @@ footer .wp-block-image img { margin-left: 0.5rem; width: 1rem; } -.awasqa-heading-link:hover,.awasqa-heading-link:focus { +.awasqa-heading-link a:hover,.awasqa-heading-link a:focus { text-decoration: underline; } .awasqa-issue-link { @@ -460,3 +462,7 @@ footer .wp-block-image img { background-color: var(--color-green-lightest); color: var(--color-green); } +.awasqa-related-posts { + margin-bottom: var(--wp--preset--spacing--50); + margin-top: -0.75rem; +} diff --git a/web/app/themes/awasqa/styles/awasqa.css b/web/app/themes/awasqa/styles/awasqa.css index fc9094b..97aba04 100644 --- a/web/app/themes/awasqa/styles/awasqa.css +++ b/web/app/themes/awasqa/styles/awasqa.css @@ -20,3 +20,4 @@ @import "blocks/post-heading.css"; @import "blocks/post-source.css"; @import "blocks/radical-resilience.css"; +@import "blocks/related-posts.css"; diff --git a/web/app/themes/awasqa/styles/blocks/authors-column.css b/web/app/themes/awasqa/styles/blocks/authors-column.css index fba2dc1..9f17cd6 100644 --- a/web/app/themes/awasqa/styles/blocks/authors-column.css +++ b/web/app/themes/awasqa/styles/blocks/authors-column.css @@ -1,3 +1,11 @@ .awasqa-authors-column { margin-bottom: 5.625rem; -} \ No newline at end of file + + h6 { + margin-top: 0; + } + + .awasqa-author-column { + margin-bottom: var(--wp--style--block-gap); + } +} diff --git a/web/app/themes/awasqa/styles/blocks/footer.css b/web/app/themes/awasqa/styles/blocks/footer.css index 44d6cdc..81b727a 100644 --- a/web/app/themes/awasqa/styles/blocks/footer.css +++ b/web/app/themes/awasqa/styles/blocks/footer.css @@ -5,10 +5,3 @@ footer { } } } - -/* Prevent gap between single post background color and footer */ -.single-post { - footer { - margin-top: 0; - } -} diff --git a/web/app/themes/awasqa/styles/blocks/heading-link.css b/web/app/themes/awasqa/styles/blocks/heading-link.css index bc48990..f48b363 100644 --- a/web/app/themes/awasqa/styles/blocks/heading-link.css +++ b/web/app/themes/awasqa/styles/blocks/heading-link.css @@ -1,3 +1,3 @@ -.awasqa-heading-link { +.awasqa-heading-link a { @apply --link-arrow; } \ No newline at end of file diff --git a/web/app/themes/awasqa/styles/blocks/related-posts.css b/web/app/themes/awasqa/styles/blocks/related-posts.css new file mode 100644 index 0000000..8e7e530 --- /dev/null +++ b/web/app/themes/awasqa/styles/blocks/related-posts.css @@ -0,0 +1,4 @@ +.awasqa-related-posts { + margin-bottom: var(--wp--preset--spacing--50); + margin-top: -0.75rem; +} \ No newline at end of file