Soliloquy Documentation

Documentation, Reference Materials, and Tutorials for Soliloquy

Featured Content: Display Date and Categories

Important: This doc assumes you’re comfortable creating and/or editing PHP files in your WordPress installation and is intended for advanced users.

You can display Post Dates and Categories on your Soliloquy Featured Content sliders following this guide.

Step 1 – Create Plugin File

The first step is to create a new php file in the wp-content/plugins/ directory of your WordPress installation. The easiest way to do this is using your favorite FTP program or through your web hosting account’s file editor (if they provide one).

Once you’ve navigated to the wp-content/plugins/ directory, create a new file with the name soliloquy-featured-content-date-terms.php

Step 2 – Edit the New Plugin File

Next, you’ll want to copy and paste the following code into the soliloquy-featured-content-date-terms.php plugin file you’ve created:

<?php
/**
* Plugin Name: Soliloquy - Featured Content Addon - Display Date and Taxonomy Terms
* Plugin URI: https://soliloquywp.com
* Version: 1.0
* Author: Tim Carr
* Author URI: http://www.n7studios.co.uk
* Description: Adds the Published Date and Taxonomy Terms for Featured Content slides
*/

/**
* Adds the Published Date and Taxonomy Terms for Featured Content slides
*
* @param string $content HTML Anchor
* @param WP_Post $post Featured Content Post
* @param array $data Soliloquy Slider Configuration Data
* @return string HTML Anchor
*/
function sol_soliloquy_fc_date_terms( $content, $post, $data ) {
	
 	// Start Config
	$sliderSlugs = array(
		'my-slug',
	);
	
	// 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 = 	__( 'Published on ', 'soliloquy-featured-content-date-terms' ) . 
							get_the_date( 'dS F Y', $post->ID ) . 
							__( ' in ' ) . 
							get_the_term_list( $post->ID, 'category', 'Categories: ', ', ' );

	// Return content
	return $content . $additional_content;

}
add_filter( 'soliloquy_fc_caption', 'sol_soliloquy_fc_date_terms', 1, 3 );

Step 3 – Edit File As Necessary

You’ll need to adjust the $sliderSlugs and taxonomy called in get_the_term_list to meet your specific requirements.

Step 4 – Activate the New Plugin

The last step is to navigate to the WordPress Admin > Plugins screen, locate the plugin named Soliloquy – Featured Content Addon – Display Date and Taxonomy Terms and activate the plugin.

That’s it! You’ve successfully enabled your Featured Content sliders to display the Date and Category!

[i]
[i]