Soliloquy Documentation

Documentation, Reference Materials, and Tutorials for Soliloquy

Featured Content: Display Date, Author and Categories

Would you like to add the author, date and category to your featured content sliders? This is as simple as creating a custom plugin and copying our code. We’ll walk you through the steps on how to add some extra fields to your featured content sliders.

Note: This walk through is a little more technical than our other tutorials. But we’ll walk you through the process step by step. In order to add these new fields to your featured content sliders we’ll need to create and upload a basic WordPress plugin.


Creating the Plugin

First you’ll need to add the following code to a new file at wp-content/plugins/soliloquy-add-date-category-fc-slider.php.

[php]<?php
/**
* Plugin Name: Soliloquy – Display Date and Taxonomy Terms on Featured Content Sliders
* Plugin URI: https://soliloquywp.com
* Version: 1.0
* Author: Soliloquy Team
* Author URI: https://soliloquywp.com
* Description: Adds the Published Date, Author and Taxonomy Terms for Featured Content slides
*/

function sol_soliloquy_fc_date_terms( $content, $post, $data ) {

// Start Config
$sliderSlugs = array(
‘your-slider-slug-name’,
);

// Check slider ID is the one we want to amend
if ( ! in_array( $data[‘config’][‘slug’], $sliderSlugs ) ) {
return $content;
}

// Build date and taxonomy terms content
$additional_content =
‘<div class="soliloquy-fc-author-name">’
. __( ‘Posted by: ‘, ‘soliloquy-featured-content-date-terms’ ) . get_the_author_meta( ‘display_name’, $post->post_author ) . ‘
</div>’;
‘<div class="soliloquy-fc-date">’
. __( ‘Published on ‘, ‘soliloquy-featured-content-date-terms’ ) . get_the_date( ‘dS F Y’, $post->ID ) . ‘
</div>’;
‘<div class="soliloquy-fc-category"> ‘
. __( ‘in ‘, ‘soliloquy-featured-content-date-terms’ ) . get_the_term_list( $post->ID, ‘category’, ‘Categories: ‘, ‘, ‘ ) . ‘
</div>’;

// Return content
return $content . $additional_content;

}
add_filter( ‘soliloquy_fc_caption’, ‘sol_soliloquy_fc_date_terms’, 1, 3 );[/php]

If you’re unsure how to create a plugin file, follow these steps below:

  1. Open a text file and make sure that it is a plain text document. You can use a plain text editor like Notepad or a code editor of your choice.
  2. Next, copy and paste the code shown above into the file and save the file as soliloquy-add-date-category-fc-slider.php
  3. Once you’ve saved the file you can easily upload this directly to your /plugins directory on your server using FTP or you can right-click on the text document and zip (or compress).
  4. Finally, log in to your WordPress dashboard and go to Plugins » Add New » Upload Plugin and upload the .zip file you just created in the previous step.

Get your slider slug name

Remember to change the $sliderSlugs and the get_the_term_list to match your needs.

In order to find your slider slug name just edit the slider and in the Soliloquy Slider Code sidebar you’ll see the slug name.

Remember to update the plugin code with the slider slug names

If you’d like to add more than 1 slider, just separate the slider slug names by commas.

In order to find the taxonomy of the term you want to use, this would depend on the plugin or code your using.

For our example, we’re going to use the post categories.

The name for WordPress Categories is called category.

Activate the Plugin

Your last step is to activate the plugin. To do this, just go to the Plugins from within your WordPress dashboard and activate the Soliloquy – Display Date and Taxonomy Terms on Featured Content Sliders plugin.

Activate the custom plugin to add the author, date and category to your featured content sliders

The CSS (optional)

In addition to adding these fields, you may want to style them as well. As shown below we’ve given you some basic CSS to get you started on styling the new fields.

[css].soliloquy-fc-author-name {
float: left;
display: inline-block;
margin-left: 5px;
margin-top: 10px;
}
.soliloquy-fc-date {
float: left;
display: inline-block;
margin: 10px 5px 0 5px;
}
.soliloquy-fc-category {
clear: both;
margin: 10px 0;
display: inline-block;
}
.soliloquy-fc-category a {
color: #ffffff;
}
.soliloquy-fc-category a:hover {
color: #ffffff;
text-decoration: underline;
}[/css]

And that’s it! Would you like to try out styling the Soliloquy captions? Take a look at our article on How to Customize the Soliloquy Caption.