Forked from calliaweb/add-pages-to-soliloquy-featured-content-slider.php
Last active
August 29, 2015 13:56
-
-
Save GaryJones/8892384 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Do NOT include the opening php tag above | |
add_filter( 'tgmsp_individual_slide', 'jmw_soliloquy_add_custom_slides', 10, 4 ); | |
/** | |
* Filter the slide html to append another slide. | |
* | |
* @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 integer $slide_id ID of the slide. | |
* | |
* @return string Amended slider HTML. | |
*/ | |
function jmw_soliloquy_add_custom_slides( $slider_html, $slider_id, $image, $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' !== $slider_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 $add_slide_html 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 ) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment