Last active
December 31, 2015 11:28
-
-
Save mclanecreative/7979441 to your computer and use it in GitHub Desktop.
Adds an events panel to WooThemes homepage component. To add functionality for The Events Calendar into the theme options, drop this file into a child theme of any WooThemes theme. Example: ...child-theme-name/includes/homepage-event-panel.php
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 | |
/** | |
* Homepage Events Panel | |
* Created by Adam McLane | |
*/ | |
/** | |
* The Variables | |
* | |
* Setup default variables, overriding them if the "Theme Options" have been saved. | |
*/ | |
$settings = array( | |
'tribe_entries' => 6, | |
'tribe_title' => '', | |
'tribe_message' => '', | |
'tribe_link_text' => __( 'View more events', 'woothemes' ), | |
'tribe_link_URL' => '', | |
'tribe_order' => 'ASC', | |
'tribe_linkto' => 'post' | |
); | |
$settings = woo_get_dynamic_values( $settings ); | |
$orderby = 'date'; | |
if ( $settings['tribe_order'] == 'rand' ) | |
$orderby = 'rand'; | |
?> | |
<section id="portfolio" class="home-section fix"> | |
<header class="block"> | |
<h1><?php echo stripslashes( $settings['tribe_title'] ); ?></h1> | |
<p><?php echo stripslashes( $settings['tribe_message'] ); ?></p> | |
<a class="more" href="<?php if ( $settings['tribe_URL'] != 'tribe_URL' ) echo $settings['tribe_link_URL']; else echo get_post_type_archive_link('events'); ?>" title="<?php $settings['tribe_link_text']; ?>"><?php echo $settings['tribe_link_text']; ?></a> | |
</header> | |
<?php | |
$count = 0; | |
$args = array( | |
'post_type' => 'tribe_events', | |
'numberposts' => $settings['tribe_entries'], | |
'suppress_filters' => 0, | |
'order' => $settings['tribe_order'], | |
'orderby' => $orderby | |
); | |
$portfolio = get_posts( $args ); | |
?> | |
<ul> | |
<?php | |
$original_post = $post; | |
foreach( $portfolio as $post ) : setup_postdata( $post ); $count++; | |
$rel = ''; | |
$custom_url = get_post_meta( $post->ID, '_events_url', true ); | |
if ( $custom_url != '' ) | |
$permalink = $custom_url; | |
else | |
$permalink = get_permalink( get_the_ID() ); | |
if ( $settings['events_linkto'] == 'lightbox' ) { | |
if ( $custom_url == '' ) | |
$permalink = woo_image( 'return=true&link=url' ); | |
$rel = ' rel="lightbox[\'home\']"'; | |
} | |
$lightbox_url = get_post_meta( $post->ID, 'lightbox-url', true ); | |
if ( isset($lightbox_url) && $lightbox_url != '' ) { | |
if ( $custom_url == '' ) | |
$permalink = $lightbox_url; | |
} | |
$image = woo_image( 'width=200&height=200&link=img&return=true' ); | |
if ( ! $image ) { | |
$image = '<img src="'.get_template_directory_uri() . '/images/temp-portfolio.png" alt="" />'; | |
$rel = ''; // Prevent items without images from displaying in the lightbox. | |
} | |
?> | |
<li <?php if( $count % 3 == 0 ) echo 'class="last"'; ?>> | |
<article class="portfolio-item drop-shadow curved curved-hz-1"> | |
<a href="<?php echo $permalink; ?>" class="item"<?php echo $rel; ?>> | |
<?php echo $image; ?> | |
<div class="mask"> | |
<div class="content"> | |
<h2><?php the_title(); ?></h2> | |
<p class="date"><?php the_time( get_option( 'date_format' ) ); ?></p> | |
</div> | |
<img class="icon" src="<?php echo get_template_directory_uri(); ?>/images/ico-portfolio-hover.png" alt="View" /> | |
</div> | |
</a> | |
</article> | |
</li> | |
<?php endforeach; ?> | |
</ul> | |
</section> | |
<?php wp_reset_query(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment