• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
Callia Web

Callia Web

Websites - Design with Purpose

  • Home
  • Websites
  • Support
  • Our Work
  • About
  • Contact

Add page to Soliloquy featured content slider

8 Feb 2014
soliloquy slider

My client wants to have a featured content slider on her home page, with two static pages in between the featured post slides. So the slider shows:

  • Latest featured post
  • Page one
  • Second featured post
  • Page two
  • Third featured post

I decided to use the Soliloquy slider for this task because:

  • It’s an awesome slider
  • It has a featured content add-on
  • It comes with lots of hooks and filters so you can modify the output

I\’ll not go over setting up the slider and the featured content add-on as there is plenty of information on the Soliloquy website but I will go over how I added slides for the pages between the featured content slides.

Inserting static pages into featured content slider

I started with appending custom slides to your slider code from the Soliloquy website. (Please note that currently this tutorial on the Soliloquy website is for the old version of Soliloquy and the hook has changed.)

I added a conditional for appending my page slides to either the end of the first slide or the second slide.

In the jmw_soliloquy_generate_slide_html function, I use the page id to get the featured image URL and the page title to form the page slide HTML, which is then returned.

I have manually identified the id of the slider and the page id of the pages I want to add. I have also assumed that there will be at least 2 slides of featured content. All of which isn\’t ideal but without building an admin page I couldn\’t see another way.

This code goes into your functions.php file.

Update 2014-02-09: Big thanks to Gary Jones for improving the code to what you now see below.

Update 2014-05-7: I\’ve updated this code to work with Soliloquy 2 using the new soliloquy_output_single_item hook.

You can also see the code below on github if you prefer.

add_filter( 'soliloquy_output_single_item', 'jmw_soliloquy_add_custom_slides', 10, 5 );
/** 
 * Filter the Soliloquy slide html to append another slide. Works with version 2 of Soliloquy.
 *
 * @link http://soliloquywp.com/docs/appending-custom-slides-to-your-slider/
 *
 * @param string  $slider_html Existing slide HTML.
 * @param string  $slider_id   ID of the slider.
 * @param array   $image       Array of slide image details.
 * @param array   $data        Array of slider config data.
 * @param integer $slide_id    ID of the slide.
 *
 * @return string Amended slider HTML.
 */
function jmw_soliloquy_add_custom_slides( $slider_html, $slider_id, $image, $data, $slide_id ) {
 
	// Bail out early if we are not targeting our specific slider. Remove this if you want it to apply to all sliders.
	if ( 2843 !== $data['id']) {
		return $slider_html;
	}
	
	if ( 1 == $slide_id ) { // Add a slide after first post slide  	
		$slider_html .= jmw_soliloquy_generate_slide_html( '2763' );
	} elseif ( 2 == $slide_id ) { // Add a slide after second post slide
		$slider_html .= jmw_soliloquy_generate_slide_html( '2769' );
	}
 
	// Return the amended slider HTML with our custom slides.
	return $slider_html;
}
 
/** 
 * Generate slide html string for given page id.
 *
 * @param string  $page_id	The Page ID to generate the slide from.
 * 
 * @return string  		The HTML string for the slide.
 */
function jmw_soliloquy_generate_slide_html( $page_id ) {
	return sprintf(
		'<li class="soliloquy-item"><a href="%1$s"><img class="soliloquy-item-image" src="%2$s" title="%3$s" alt="%3$s" /></a><div class="soliloquy-caption"><div class="soliloquy-caption-inside soliloquy-fc-caption"><h2 class="soliloquy-fc-title">%4$s</h2></div></div></li>',
		esc_url( get_permalink( $page_id ) ),
		esc_url( wp_get_attachment_url( get_post_thumbnail_id( $page_id ) ) ),
		esc_attr( get_the_title( $page_id ) ),
		get_the_title( $page_id )
	);
}

Featured Image: Photo by rawpixel on Unsplash

Share this post:

Share on FacebookShare on LinkedInShare on E-mailShare on WhatsApp

About Jo Waltham

Jo Waltham is the founder of Callia Web and is passionate about helping people with their websites.

Liked this post? Subscribe to get our next post direct to your inbox.


Previous Post:Help my WordPress visual editor is blank!
Next Post:Google Drive won’t sync to new Google Apps account

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Ready to get started?

Get in touch

Ask Callia Web’s AI

Contact us

Telephone: 01672 666001

Email: hello@calliaweb.co.uk

Quick links

Websites

Our work

Testimonials

About

Blog

Popular posts

Using headings in WordPress

Accessibility basics

Image sizes and aspect ratios

Making images equal size

Beginner’s guide to Analytics

Legal

Privacy policy / Cookie policy

Terms of service

Company number: 08316519

Registered address: Bowman House, Royal Wootton Bassett, Wiltshire, SN4 7DB

Copyright © 2025 · Callia Web Ltd · All Rights Reserved