/ Published in: PHP
This creates a custom page template designed to run a Facebook photo contest utilizing the Facebook like button and uses Wordpress featured images for each post in a grid.
This setup requires the following:
- iLoveIt Wordpress Theme
- Create contest category for contestant entries
-Create contest page and select the contest page template.
- Gravity forms to create a custom contestant entry form with the following.
( Post title, Post Body, Featured Image, Email, etc.
Instructions:
The below snippet will add the FB like button below the featured image and add a custom voting text for the entry.
Step 1:
Go to your single.php and add this snippet below line 85. Items that need changed are in CAPS.
This setup requires the following:
- iLoveIt Wordpress Theme
- Create contest category for contestant entries
-Create contest page and select the contest page template.
- Gravity forms to create a custom contestant entry form with the following.
( Post title, Post Body, Featured Image, Email, etc.
Instructions:
The below snippet will add the FB like button below the featured image and add a custom voting text for the entry.
Step 1:
Go to your single.php and add this snippet below line 85. Items that need changed are in CAPS.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /* Template Name: Contest Page Template */ ?> <style> #contestant img{ min-width: 210px !important; min-height: 200px !important; max-width: 210px !important; max-height: 200px !important } #contest_wrap{ width: 100%; padding: 10px } #contestant{ float: left; display: inline-block; max-width: 210px; max-height: 240px; width: 210px; height: 240px; text-align: center; margin-left: 18px; margin-bottom: 30px } #contestant h3{ font-weight: normal; font-size: 16px !important; color: #464646 } .share{ margin-left: 145px; padding-top: 10px } </style> <?php if( $post -> ID == options::get_value( 'general' , 'user_profile_page' ) ){ get_template_part( 'user_profile_update' ); } get_header(); ?> <div class="b_content clearfix" id="main"> <?php while( have_posts () ){ the_post(); $post_id = $post -> ID ?> <div class="content-title"> <div class="left"> </div> <div class="title"> <h1 class="entry-title"> <span> <?php if( (int)options::get_value( 'general' , 'my_posts_page' ) == $post_id ){ _e( 'My posts' , 'cosmotheme' ); }else{ the_title(); } ?> </span> </h1> </div> <div class="right"> </div> </div> <!-- Start content --> <div class="b_page clearfix"> <!-- left sidebar --> <?php layout::side( 'left' , $post_id , 'page'); ?> <div id="primary" <?php tools::primary_class( $post_id , 'page' ); ?>> <div id="content" role="main"> <?php if( (int)options::get_value( 'general' , 'my_posts_page' ) == $post_id ){ ?> <div class="w_<?php echo layout::length( $post_id , 'page' ); ?> my-posts"><!--add class my posts--> <div class="list"> <?php post::my_posts( get_current_user_id() ); ?> </div> </div> <?php }else{ ?> <div <?php tools::content_class( $post_id , 'page' , '' , false ); ?>> <?php if( $post_id == options::get_value( 'upload' , 'post_item_page' ) ){ get_template_part( 'post_item' ); }elseif( $post_id == options::get_value( 'general' , 'user_profile_page' ) ){ get_template_part( 'user_profile' ); }else{ ?> <!-- post --> <article id="post-<?php the_ID(); ?>" <?php post_class( 'post' , $post -> ID ); ?>> <!-- header --> <?php $template = 'page'; $attr = tools::login_attr( $post -> ID , 'nsfw mosaic-overlay' , get_permalink( $post -> ID ) ); $size = 'tmedium'; $s = image::asize( image::size( $post->ID , $template , $size ) ); if( options::logic( 'general' , 'enb_featured' ) ){ if ( has_post_thumbnail( $post -> ID ) && get_post_format( $post -> ID ) != 'video' ) { $src = image::thumbnail( $post -> ID , $template , $size ); $caption = image::caption( $post -> ID ); ?> <!-- thumbnail --> <header class="entry-header"> <div class="featimg"> <div class="img"> <?php echo '<img src="' . $src[0] . '" alt="' . $caption . '" >'; ?> </div> </div> </header> <?php } } ?> <!-- content --> <div class="entry-content"> <div class="b_text"> <?php the_content(); ?> </div> <?php global $post; $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <div id="contestant"> <div style="margin-top: 130px; margin-left: 150px; z-index: 10; position: absolute"> <iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&layout=box_count&show_faces=false&width=90&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:120px; height:60px"></iframe></div> <?php the_post_thumbnail( 'single-post-thumbnail' ); ?> <div style="clear: both"></div> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <div style="clear: both"></div> <?php the_content ?> </div> <?php endforeach; ?> </div> </div> <!-- footer --> <footer class="entry-footer"> <div class="share"> <?php get_template_part('social-sharing'); ?> </div> <?php ?> <div class="cosmo-ads zone-2"> <?php echo options::get_value( 'advertisement' , 'content' ); ?> </div> <?php } ?> </footer> </article> <p class="delimiter blank"> </p> <?php /* comments */ if( comments_open() ){ if( options::logic( 'general' , 'fb_comments' ) ){ ?> <div id="comments"> <h3 id="reply-title"><?php _e( 'Leave a reply' , 'cosmotheme' ); ?></h3> <p class="delimiter"> </p> <fb:comments href="<?php the_permalink(); ?>" num_posts="5" width="620" height="120" reverse="true"></fb:comments> </div> <?php }else{ comments_template( '', true ); } } } ?> </div> <?php } ?> </div> </div> <!-- right sidebar --> <?php layout::side( 'right' , $post_id , 'page' ); ?> </div> <?php } ?> </div> <?php get_footer(); ?>