Soliloquy Documentation

Documentation, Reference Materials, and Tutorials for Soliloquy

Featured Content: Display Post Custom Field Values in Slides

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 include a Post’s Custom Fields in the content of your Featured Content slides 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-display-custom-fields.php

Step 2 – Edit the New Plugin File

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

<?php
/**
* Plugin Name: Soliloquy - Featured Content - Display Custom Fields
* Plugin URI: https://soliloquywp.com
* Version: 1.0
* Author: Tim Carr
* Author URI: http://www.n7studios.co.uk
* Description: Displays Custom Fields 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_display_custom_fields( $pcontent, $post, $data ) {

	// Get custom field values
	// If you're using ACF, you could use get_field( 'wpcf-case-story-text', $post->ID )
	$text = get_post_meta( $post->ID, 'wpcf-case-story-text', true );
	$image = get_post_meta( $post->ID, 'wpcf-case-story-image', true );

	// Append custom field values to the existing content
	// Amend as necessary
	$pcontent .= $text . $image;

	return $pcontent;

}
add_filter( 'soliloquy_fc_post_content', 'sol_soliloquy_featured_content_display_custom_fields', 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 – Display Custom Fields and activate the plugin.

That’s it! You’ve successfully included your Post’s Custom Fields in the content of your Featured Content slider!


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]