I just whipped this up in ChatGPT after realizing there isn’t one available for some reason.
<?php
/*
Plugin Name: Custom Citation Plugin
Description: Generate custom citations for your content.
Author: Justin Charnell
Version: 1.1
*/
function generate_citation($style) {
$author_first = get_the_author_meta('first_name');
$author_last = get_the_author_meta('last_name');
$page_title = get_the_title();
$current_date = date('j F Y');
$permalink = get_permalink();
$website_name = get_bloginfo('name');
// Format the author's first name with only the first letter capitalized for APA style.
$author_first_apa = ucfirst(substr($author_first, 0, 1));
// Format the date for APA style and Chicago style.
$current_date_apa = date('Y, F j');
$current_date_chicago = date('F j, Y');
$citation = '';
if ($style === 'mla') {
$citation = "$author_last, $author_first. \"$page_title.\" <i>$website_name</i>, $current_date, $permalink.";
} elseif ($style === 'apa') {
$citation = "$author_last, $author_first_apa. ($current_date_apa). <i>$page_title</i>. $website_name. $permalink";
} elseif ($style === 'chicago') {
$citation = "$author_first $author_last, \"$page_title,\" <i>$website_name</i>, (accessed $current_date_chicago). $permalink.";
}
return $citation;
}
function mla_citation_shortcode() {
return generate_citation('mla');
}
add_shortcode('mla_citation', 'mla_citation_shortcode');
function apa_citation_shortcode() {
return generate_citation('apa');
}
add_shortcode('apa_citation', 'apa_citation_shortcode');
function chicago_citation_shortcode() {
return generate_citation('chicago');
}
add_shortcode('chicago_citation', 'chicago_citation_shortcode');
All it does is pull information from your post/page and display it in your post with shortcodes.
I’m using it for a reference site I’m building by using GenerateBlocks Elements to insert it dynamically into the sidebar of every post on the site. That way, if people want to reference it, they can do so easily.
MLA Citation
APA Citation
Chicago Citation
Have fun.