EOM Designate Primary Post Category
Designate a single primary category for WordPress posts
by Josh Smith · github.com/joshsmith01/eom-designate-primary-post-category · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/joshsmith01/eom-designate-primary-post-category/archive/refs/heads/master.zipReadme
EOM Designate Primary Post Category
Contributors: joshsmith01
Donate link: https://www.efficiencyofmovement.com
Tags: comments, category, primary
Requires at least: 3.0.1
Tested up to: 3.4
Stable tag: trunk
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Designate a primary category for posts.
Description
Enhance post categories by adding a primary category. Use this plugin to add a dropdown of categories to the Categories meta box in the Post edit screen. Content creators can determine the primary category from that dropdown list.
Installation
Download
- Visit the homepage for this plugin: https://github.com/joshsmith01/eom-designate-primary-post-category
- Download the .zip file
- Unzip the .zip to you computer
- Upload
eom-designate-primary-post-category.phpto the/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
Git
- Open a terminal and navigate to the
wp-content/pluginsdirectory - Clone the repo:
git clone git@github.com:joshsmith01/eom-designate-primary-post-category.git
Frequently Asked Questions
Will I lose my categories if I stop using this plugin?
No, this plugin essentially duplicates the existing categories meta data and adds a primary category to it. If you delete this plugin, all of the categories will remain.
Changelog
1.0.0
- Initial launch
Query for posts with a Primary Category
Now that you have a Primary Category attached to your posts you will want to query for posts based on their Primary Category. Below is a quick snippet that uses the built-in WordPress Query to retrieve posts with the Primary Category of your specification. The important part of the query is the supplied arguments that use the Meta Key of _primary_category.
In the snippet below, the meta_value of "Happy" is supplied, but it should be whatever value of your Primary Category is that you want to display. The snippet below is also searching in the WordPress post type of "post", but also the WordPress Custom Post type of "book".
Don't forget to check if the plugin is active first.
<?php
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if( is_plugin_active( 'eom-designate-primary-post-category/eom-designate-primary-post-category.php' ) ) {
// EOM designate Primary Post Category is active
$args = array(
'meta_value' => 'Happy',
'meta_key' => '_primary_category',
'post_type' => array('book', 'post'),
);
$query = new WP_Query( $args );
}
Find more information about querying by Post Meta in the WordPress Developer Documentation.
A brief Markdown Example
Ordered list:
- Some feature
- Another feature
- Something else about the plugin
Unordered list:
- something
- something else
- third thing
Here's a link to WordPress and one to Markdown's Syntax Documentation. Titles are optional, naturally.
"Markdown is what the parser uses to process much of the readme file"
Markdown uses email style notation for blockquotes and I've been told:
Asterisks for emphasis. Double it up for strong.
<?php code(); // goes in backticks ?>