Skip to content

Instantly share code, notes, and snippets.

@tinothepro
Last active May 24, 2017 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tinothepro/99481481842918b3624ce90ed4fc42f4 to your computer and use it in GitHub Desktop.
Save tinothepro/99481481842918b3624ce90ed4fc42f4 to your computer and use it in GitHub Desktop.
Carbon Slideshow plugin
<?php // Import carbon field configuration
add_action('carbon_register_fields', 'wpd_register_meta');
function wpd_register_meta() {
include_once(dirname(__FILE__) . '/includes/carousel.php');
}
if ( ! function_exists( 'carbon_get_post_meta' ) ) {
function carbon_get_post_meta( $id, $name, $type = null ) {
return false;
}
}
if ( ! function_exists( 'carbon_get_the_post_meta' ) ) {
function carbon_get_the_post_meta( $name, $type = null ) {
return false;
}
}
if ( ! function_exists( 'carbon_get_theme_option' ) ) {
function carbon_get_theme_option( $name, $type = null ) {
return false;
}
}
<?php function carousel() {
$slides = carbon_get_post_meta(get_the_ID(), 'carousel', 'complex');
$slide_count = 0;
if ( $slides ) { ?>
<div id="carousel-container">
<?php foreach ($slides as $slide) { ?>
<?php $image = wp_get_attachment_url( $slide['image'] ); ?>
<div class="carousel-slide slide-<?php echo $slide_count; ?>" style="z-index: -9999px; background-image: url(<?php echo $image; ?>)"></div>
<?php $slide_count++; } ?>
</div>
<?php }
}
add_action('genesis_after_header', 'carousel');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment