Version: 1.3.0
Requires at least: 4.0
Tested up to: 4.8, (*1)
Display additional content before or after post content in single post pages. Add content (for example shortcodes) on a post per post basis in the edit or publish Post screen., (*2)
, (*3)
Installation
Install via Composer into your WordPress plugins directory:, (*4)
composer create-project keesiemeijer/additional-content
Or clone the GitHub repository in the plugins directory:, (*5)
git clone https://github.com/keesiemeijer/additional-content.git
Or download it directly as a ZIP file, (*6)
PHP requirements
This plugin requires the WordPress recommended PHP version of 5.4.0 or greater., (*7)
WordPress has PHP 5.2.4 as the minimum required version. This is a version that has been unsupported since early 2011. The PHP 5.3.* versions have been unsupported since August 2014 as well. This means that these versions don't receive any updates, which leaves them potentially insecure. http://www.wpupdatephp.com, (*8)
Note: The plugin shows a notice when activated on the older PHP versions.
, (*9)
What is the priority option?
This plugin is basically a user interface for the_content filter. This filter allows themes and plugins to change (or add content to) post content before it's displayed. The default priority for filters is 10. Higher numbers correspond with later execution of adding additional content. This option allows you to display the additional content before or after other plugins that add content with this filter., (*10)
HTML in additional content
The same html tags that are allowed in the post (text) editor can be used in additional content. If you want to use <script>
tags in the content the user has to have the unfiltered_html capability (superadmin, admin and editor role)., (*11)
Changing the metabox text strings
Let's say you want to use this plugin for authors to add shortcodes after the content on single post pages. All metabox text strings can be changed with the additional_content_metabox_text
filter. Put this in your (child) theme's functions.php file or use it in a plugin., (*12)
add_filter( 'additional_content_metabox_text', 'change_additional_content_text_strings' );
function change_additional_content_text_strings( $text ) {
$text['title'] = __( 'Add Shortcodes', 'additional-content' );
$text['content'] = __( 'Shortcode', 'additional-content' );
$text['prepend_content'] = __( 'Prepend Shortcode', 'additional-content' );
$text['append_content'] = __( 'Append Shortcode', 'additional-content' );
$text['prepend_append_content'] = __( 'Prepend and Append Shortcode', 'additional-content' );
$text['prepend'] = __( 'Prepend shortcode', 'additional-content' );
$text['append'] = __( 'Append shortcode', 'additional-content' );
$text['priority'] = __( 'Priority', 'additional-content' );
$text['add_row'] = __( 'Add shortcode', 'additional-content' );
$text['add_more_row'] = __( 'Add more shortcodes', 'additional-content' );
$text['remove_row'] = __( 'Remove', 'additional-content' );
$text['header_info'] = __( 'Add shortcodes to the post content on single post pages. ', 'additional-content' );
$text['priority_info'] = '';
return $text;
}
, (*13)
Options Display
The prepend, append and priority fields can be removed with the additional_content_metabox_options
filter. Put this in your (child) theme's functions.php file or use it in a plugin., (*14)
add_filter( 'additional_content_metabox_options', 'remove_additional_content_options' );
function remove_additional_content_options( $options ) {
$options['append_prepend'] = false;
$options['priority'] = false;
return $options;
}
, (*15)
Additional content on other pages than single posts
Use the additional_content_add_content
filter if you want additional content to display on other pages as singular post pages. Put this in your (child) theme's functions.php file or use it in a plugin. This example adds the additional content to home page posts., (*16)
add_filter( 'the_content', 'additional_content_home_page' );
function additional_content_home_page( $content ) {
// Check if we're on the home page
if ( !is_home() ) {
return $content;
}
// Check if this is the main query and inside the loop.
if ( in_the_loop() && is_main_query() ) {
// Check if the plugin function get_content() exists.
if ( function_exists( 'keesiemeijer\Additional_Content\\get_content' ) ) {
// Add the additional content to the post content with the get_content() function.
// Content and post id are required.
// Post id is available inside the loop.
$content = keesiemeijer\Additional_Content\get_content( $content, get_the_ID() );
}
}
return $content;
}