Soliloquy Documentation

Documentation, Reference Materials, and Tutorials for Soliloquy

Featured Content: Exclude Current Post from Sliders

Would you like to exclude current post from Featured Content sliders? If you’ve added a Featured Content slider to your post but don’t want the current post to display in the slider, just follow the directions below and we’ll help you with that!

Note: This tutorial is a bit more technical than our other docs, but we’ll walk you through the process step by step. In order to exclude the current post from Featured Content sliders, we’ll need to create and upload a basic WordPress plugin.


Creating the Plugin

To the current post from your Featured Content sliders, just add the following code to a new file at wp-content/plugins/soliloquy-fc-exclude-current-post.php.

<?php
/**
* Plugin Name: Soliloquy - Featured Content - Exclude Current Post
* Plugin URI: http://soliloquywp.com
* Version: 1.0
* Author: Soliloquy Team
* Author URI: http://soliloquywp.com
* Description: Excludes the current singular Post, Page or CPT from the Featured Content Slider
*/

function sol_soliloquy_fc_exclude_current_post( $query_args, $id, $data ) {

if( is_singular() && !isset( $args['post__in'] ) )
            $args['post__not_in'] = array( get_the_ID() );
        return $args;
	
}
add_filter( 'soliloquy_fc_query_args', 'sol_soliloquy_fc_exclude_current_post', 10, 3 );

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-fc-exclude-current-post.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.

Activate the Plugin

Your next step is to activate the plugin you just uploaded. Simply navigate to the Plugins from within your WordPress dashboard and activate the Soliloquy – Featured Content – Exclude Current Post plugin.

To exclude the current post from your featured content slider, activate the custom plugin

And that’s it! Would you like to add the author and category to your Featured Content slider? Have a look at our tutorial on How to Display Date, Author and Categories.

[i]
[i]