Return to Snippet

Revision: 59985
at October 13, 2012 08:27 by SmashArtist


Initial Code
<?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">&nbsp;</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">&nbsp;</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;

$args = array( 'numberposts' => 20, 'offset'=> 0, 'category' => 202 );

$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)); ?>&amp;layout=box_count&amp;show_faces=false&amp;width=90&amp;action=like&amp;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

                                            if( strlen( options::get_value( 'advertisement' , 'content' ) ) > 0 ){

                                        ?>

                                                <div class="cosmo-ads zone-2">

                                                    <?php echo options::get_value( 'advertisement' , 'content' ); ?>

                                                </div>

                                        <?php

                                            }

                                        ?>

                                    </footer>

                                </article>



                                <p class="delimiter blank">&nbsp;</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">&nbsp;</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(); ?>

Initial URL


Initial Description
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.

<?php>
                                               
<div> <h1> Vote for <?php> by hitting like! >></h1></div><div><iframe>ID)); ?>&amp;layout=box_count&amp;show_faces=false&amp;width=90&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:120px; height:60px"></iframe></div> <h3>VOTE FOR ME!!!</h3>
                                                </div>
                                                <style> <!--hide> .share{display: none }</style>
<?>



Step 2:
Copy the template code and save it to your theme root as contest-page.php. You will then be able to assign the contest template to page that will show all entries in a grid layout, each photo will have it's own like button.

 

**Extra notes: You can still integrate this into any Wordpress theme, you'll just have to change it to fit your current theme. 
Overall at least you have an idea of how this can be achieved and it is very powerful in terms of drawing traffic to your site.

Initial Title
iLoveIt Wordpress Theme FB photo contest page template

Initial Tags
wordpress, theme, facebook

Initial Language
PHP