From 85f32c02f80286094cc5230a30cd7ebbe77eae2d Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sat, 14 Feb 2026 19:15:40 +0000
Subject: [PATCH] =added functions for outputting custom meta fields for our post types
---
content/art.php | 86 +++++++++++++++++++++++++++---------------
1 files changed, 55 insertions(+), 31 deletions(-)
diff --git a/content/art.php b/content/art.php
index e8b5156..9b4abaa 100644
--- a/content/art.php
+++ b/content/art.php
@@ -145,6 +145,11 @@
'label' => 'Need',
'required' => true
],
+ 'image' => [
+ 'type' => 'upload',
+ 'multiple' => true,
+ 'label' => 'Example Image'
+ ],
'fulfilled' => [
'type' => 'textarea',
'quill' => true,
@@ -161,6 +166,11 @@
'label' => 'Want',
'required' => true
],
+ 'image' => [
+ 'type' => 'upload',
+ 'multiple' => true,
+ 'label' => 'Example Image'
+ ],
'fulfilled' => [
'type' => 'textarea',
'quill' => true,
@@ -176,41 +186,55 @@
function ajv_render_art_content(array $block, string $content):string
{
+ $out = '';
$ID = get_the_ID();
$meta = Meta::forPost($ID);
+
$fields = $meta->getAll();
- $city = (empty($fields['city'])) ? 'Edmonton' : jvbGetTermLink((int)$fields['city']);
- $form = (empty($fields['form'])) ? 'art' : jvbGetTermLink((int)$fields['form']);
-
- $style = (empty($fields['style'])) ? '' : jvbGetTermLink(explode(',',$fields['style'])[0]).' ';
- $subtitle = '<h2 class="subtitle">'.$city.' handmade '.$style.'<b>'.$form.'</b>.</h2>';
-
-
- /** INTRO **/
- $intro = '<section id="intro" class="row"><div class="text">'.apply_filters('wpautop', $fields['post_excerpt']).'</div><div class="images">';
- $intro .= (!empty($fields['post_thumbnail'])) ? jvbImageCaption($fields['post_thumbnail']) : '';
- if (!empty($fields['gallery'])) {
- $images = explode(',',$fields['gallery']);
- foreach ($images as $image) {
- $intro .= jvbImageCaption($image, 'tiny', 'medium');
- }
- }
- $intro .= '</section>';
-
-
- /** META **/
- $taxonomies = ['city', 'project','form', 'media','style','theme'];
- $meta = '';
- foreach ($taxonomies as $taxonomy) {
- if (!empty($fields[$taxonomy])) {
- $icon = jvbIcon(JVB_TAXONOMY[$taxonomy]['icon'])??'';
- $meta .= jvbRenderTermList($fields[$taxonomy], $icon.JVB_TAXONOMY[$taxonomy]['singular']);
- }
- }
- if ($meta !== '') {
- $meta = '<section class="meta">'.$meta.'</section>';
+ $bits = [];
+ if (array_key_exists('post_excerpt', $fields) && !empty($fields['post_excerpt'])) {
+ $bits[] = sprintf(
+ '<section id="excerpt"><h2>At a Glance</h2>%s</section>',
+ apply_filters('the_content', $fields['post_excerpt'])
+ );
}
- return $subtitle.$meta.$intro.$meta;
+ if (array_key_exists('gallery', $fields) && !empty($fields['gallery'])) {
+ $gallery = explode(',',$fields['gallery']);
+ $gallery = array_map(function ($imgID) {
+ $out = '<figure>'.jvbFormatImage($imgID,'tiny','medium');
+ $caption = wp_get_attachment_caption($imgID);
+ $out .= ($caption && $caption !== '') ? '<figcaption>'.apply_filters('the_content', $caption).'</figcaption>' : '';
+ $out .= '</figure>';
+ return $out;
+
+ }, $gallery);
+ $gallery = implode('',$gallery);
+ $bits[] = sprintf(
+ '<section id="gallery"><h2>Gallery</h2><div>%s</div></section>',
+ $gallery
+ );
+ }
+
+ if (array_key_exists('post_content', $fields) && !empty($fields['post_content'])) {
+ $bits[] = sprintf(
+ '<section id="content">%s</section>',
+ apply_filters('the_content', $fields['post_content'])
+ );
+ }
+
+ if (array_key_exists('needs', $fields) && !empty($fields['needs'])) {
+ $bits[] = ajvb_format_needs($fields['needs']);
+ }
+ if (array_key_exists('wants', $fields) && !empty($fields['wants'])) {
+ $bits[] = ajvb_format_wants($fields['wants']);
+ }
+
+ if (!empty($bits)) {
+ $out = implode('',$bits);
+ }
+
+
+ return $out;
}
\ No newline at end of file
--
Gitblit v1.10.0