From 93ceb845aa4f76f2280841c41739278d8dfa0ee0 Mon Sep 17 00:00:00 2001
From: Kumi
Date: Thu, 20 Jun 2024 11:28:29 +0200
Subject: [PATCH] feat: add publication status taxonomy to articles
Introduced a hierarchical 'publication status' taxonomy for the 'article' post type, providing a structured way to categorize publication states. Updated front-end views to display the publication status of articles both in listings and on the single article page.
This enhancement improves the classification and visibility of articles based on their publication status, aiding in better content organization and user navigation.
---
functions.php | 31 ++++++++++++++++++++++++++++++-
index.php | 13 ++++++++++++-
single-article.php | 14 ++++++++++++++
3 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/functions.php b/functions.php
index d0d65c2..2a26ae1 100644
--- a/functions.php
+++ b/functions.php
@@ -213,9 +213,38 @@ function create_article_post_type()
register_post_type('article', $args);
}
-
add_action('init', 'create_article_post_type');
+function create_publication_status_taxonomy()
+{
+ $labels = array(
+ 'name' => _x('Publication Statuses', 'taxonomy general name', 'duck-behavior-journal'),
+ 'singular_name' => _x('Publication Status', 'taxonomy singular name', 'duck-behavior-journal'),
+ 'search_items' => __('Search Publication Statuses', 'duck-behavior-journal'),
+ 'all_items' => __('All Publication Statuses', 'duck-behavior-journal'),
+ 'parent_item' => __('Parent Publication Status', 'duck-behavior-journal'),
+ 'parent_item_colon' => __('Parent Publication Status:', 'duck-behavior-journal'),
+ 'edit_item' => __('Edit Publication Status', 'duck-behavior-journal'),
+ 'update_item' => __('Update Publication Status', 'duck-behavior-journal'),
+ 'add_new_item' => __('Add New Publication Status', 'duck-behavior-journal'),
+ 'new_item_name' => __('New Publication Status Name', 'duck-behavior-journal'),
+ 'menu_name' => __('Publication Status', 'duck-behavior-journal'),
+ );
+
+ $args = array(
+ 'hierarchical' => true,
+ 'labels' => $labels,
+ 'show_ui' => true,
+ 'show_admin_column' => true,
+ 'query_var' => true,
+ 'rewrite' => array('slug' => 'publication-status'),
+ );
+
+ register_taxonomy('publication_status', array('article'), $args);
+}
+
+add_action('init', 'create_publication_status_taxonomy', 0);
+
function add_article_meta_boxes()
{
add_meta_box(
diff --git a/index.php b/index.php
index bd80232..b2100db 100644
--- a/index.php
+++ b/index.php
@@ -40,7 +40,18 @@
?>
- Read More
+
+ name;
+ }
+ echo implode(', ', $term_list);
+ }
+ ?>
+ Read More
diff --git a/single-article.php b/single-article.php
index fb9aacf..fee5a6a 100644
--- a/single-article.php
+++ b/single-article.php
@@ -15,7 +15,21 @@
the_author();
}
?>
+
+ name;
+ }
+ echo implode(', ', $term_list);
+ }
+ ?>
+
+
+