Created
December 12, 2012 04:56
-
-
Save Sanabria/4264966 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Download Foundation at http://foundation.zurb.com/download.php (check the box for orbit if you only want the slider) | |
Add the the custom post type to your WordPress functions.php | |
Either add the scripts and CSS to the appropriate place in your theme or use equeue-scripts-styles.php in functions.php | |
Place images/foundation/orbit in your theme folder | |
Use the content-slider.php code in your page or use <?php get_template_part('content', 'slider'); ?> | |
--- | |
Foundation Orbit Slider docs: http://foundation.zurb.com/docs/orbit.php | |
This file contains hidden or 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 | |
$args = array( | |
'post_type' => 'slides', | |
'posts_per_page' => 999 | |
); | |
$temp = $wp_query; | |
$wp_query = null; | |
$wp_query = new WP_Query($args); | |
if($wp_query->have_posts()) : ?> | |
<div id="featured"> | |
<?php | |
while($wp_query->have_posts()) : $wp_query->the_post(); | |
$postid = get_the_ID(); | |
if(has_excerpt()) { | |
$datacaption = 'data-caption="#slide-'.$postid.'"'; | |
} else { | |
$datacaption = ''; | |
} | |
if(has_post_thumbnail()) { | |
$imgid = get_post_thumbnail_id($postid); | |
$alt = get_post_meta($imgid , '_wp_attachment_image_alt', true); | |
$imgurl = wp_get_attachment_url($imgid); | |
echo '<img class="orbit-slide" src="'.$imgurl.'" '.$datacaption.' alt="'.$alt.'" />'; | |
} else { | |
echo '<div class="orbit-slide" '.$datacaption.'>'; | |
echo get_the_content(); | |
echo '</div>'; | |
} | |
if(has_excerpt()) { | |
$output = '<span class="orbit-caption" id="slide-'.get_the_ID().'">'; | |
$output .= '<h4 class="slide-title">'.get_the_title().'</h4>'; | |
$output .= '<p class="slide-excerpt">'.get_the_excerpt().'</p>'; | |
$output .= '</span>'; | |
echo $output; | |
}; | |
endwhile; ?> | |
</div> | |
<?php endif; ?> | |
<?php $wp_query = null; $wp_query = $temp; wp_reset_query(); ?> |
This file contains hidden or 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
function foundry_scripts_and_styles() { | |
if (!is_admin()) { | |
wp_register_style('foundation-css', get_stylesheet_directory_uri().'/css/foundation.css', array(), '', 'all'); | |
wp_register_script('foundation-js', get_stylesheet_directory_uri().'/js/foundation.js', array(), '', true); | |
wp_register_script('app-js', get_stylesheet_directory_uri().'/javascripts/app.js', array(), '', true); | |
wp_enqueue_style('foundation-css'); | |
wp_enqueue_script('jquery'); | |
wp_enqueue_script('foundation-js'); | |
wp_enqueue_script('app-js'); | |
} | |
} | |
add_action('wp_enqueue_scripts', 'foundry_scripts_and_styles', 999); |
This file contains hidden or 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
function slides_register() { | |
$labels = array( | |
'name' => _x('Slideshow', 'post type general name'), | |
'singular_name' => _x('Slide', 'post type singular name'), | |
'add_new' => _x('Add New', 'slide'), | |
'add_new_item' => __('Add New Slide'), | |
'edit_item' => __('Edit Slide'), | |
'new_item' => __('New Slide'), | |
'all_items' => __('All Slides'), | |
'view_item' => __('View Slide'), | |
'search_items' => __('Search Slides'), | |
'not_found' => __('Nothing found'), | |
'not_found_in_trash' => __('Nothing found in Trash'), | |
'parent_item_colon' => '', | |
'menu_name' => 'Slides' | |
); | |
$args = array( | |
'labels' => $labels, | |
'public' => true, | |
'publicly_queryable' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'query_var' => true, | |
'menu_icon' => '', | |
'rewrite' => true, | |
'capability_type' => 'post', | |
'has_archive' => false, | |
'hierarchical' => false, | |
'menu_position' => 7, | |
'rewrite' => array( | |
'slug' => 'slideshow-item', | |
'with_front' => false, | |
'feed' => true, | |
'pages' => true ), | |
'supports' => array('title','editor','thumbnail', 'excerpt') | |
); | |
register_post_type('slides' , $args); | |
} | |
add_action('init', 'slides_register'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment