Soliloquy Documentation

Documentation, Reference Materials, and Tutorials for Soliloquy

Featured Content: Change Featured Image

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

Note: This document is relevant only if you have a Developer or Master license and you’re using the Featured Content Addon.

You can populate the slide image for Featured Content sliders from a custom field 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-change-featured-image.php

Step 2 – Edit the New Plugin File

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

<?php
/**
* Plugin Name: Soliloquy - Featured Content - Change Featured Image
* Plugin URI: https://soliloquywp.com
* Version: 1.0
* Author: Tim Carr
* Author URI: http://www.n7studios.co.uk
* Description: Change the Featured Image ID on Featured Content slides
*/

/**
 * Append the Post's Custom Field values onto the end of the content
 *
 * @param string $pcontent Post Content
 * @param WP_Post $post WordPress Post
 * @param array $data Slider Data
 * @return string $pcontent;
 */
function sol_soliloquy_featured_content_change_image_id( $image_id, $post, $data ) {

	// Define a different image ID.  This may be from a meta field or ACF
	$image_id = get_field( 'image_id', $post->ID );

	// Return
	return $image_id;

}
add_filter( 'soliloquy_fc_thumbnail_id', 'sol_soliloquy_featured_content_change_image_id', 10, 3 );

Step 3 – Edit the Plugin File

This example code is not plug-and-play so you’ll need to be sure and edit the code to fit your specific needs.

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 – Change Featured Image and activate the plugin.

That’s it! You’ve successfully changed the image displayed for each Post in your Featured Content sliders!


Troubleshooting

  • Be sure you’re running Soliloquy 2.x or higher
  • Be sure you’re running Soliloquy Featured Content 2.x or higher
[i]
[i]