iLoveIt Wordpress Theme FB photo contest page template


/ Published in: PHP
Save to your folder(s)

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.



Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. /*
  4.  
  5. Template Name: Contest Page Template
  6.  
  7. */
  8.  
  9. ?>
  10.  
  11. <style>
  12.  
  13. #contestant img{ min-width: 210px !important; min-height: 200px !important; max-width: 210px !important; max-height: 200px !important }
  14.  
  15. #contest_wrap{ width: 100%; padding: 10px }
  16.  
  17. #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 }
  18.  
  19. #contestant h3{ font-weight: normal; font-size: 16px !important; color: #464646 }
  20.  
  21. .share{ margin-left: 145px; padding-top: 10px }
  22.  
  23. </style>
  24.  
  25. <?php
  26.  
  27. if( $post -> ID == options::get_value( 'general' , 'user_profile_page' ) ){
  28.  
  29. get_template_part( 'user_profile_update' );
  30.  
  31. }
  32.  
  33. get_header();
  34.  
  35.  
  36.  
  37. ?>
  38.  
  39. <div class="b_content clearfix" id="main">
  40.  
  41.  
  42.  
  43. <?php
  44.  
  45. while( have_posts () ){
  46.  
  47. the_post();
  48.  
  49. $post_id = $post -> ID
  50.  
  51. ?>
  52.  
  53. <div class="content-title">
  54.  
  55. <div class="left">&nbsp;</div>
  56.  
  57. <div class="title">
  58.  
  59. <h1 class="entry-title">
  60.  
  61. <span>
  62.  
  63. <?php
  64.  
  65. if( (int)options::get_value( 'general' , 'my_posts_page' ) == $post_id ){
  66.  
  67. _e( 'My posts' , 'cosmotheme' );
  68.  
  69. }else{
  70.  
  71. the_title();
  72.  
  73. }
  74.  
  75. ?>
  76.  
  77. </span>
  78.  
  79. </h1>
  80.  
  81. </div>
  82.  
  83. <div class="right">&nbsp;</div>
  84.  
  85. </div>
  86.  
  87.  
  88.  
  89. <!-- Start content -->
  90.  
  91. <div class="b_page clearfix">
  92.  
  93.  
  94.  
  95. <!-- left sidebar -->
  96.  
  97. <?php layout::side( 'left' , $post_id , 'page'); ?>
  98.  
  99.  
  100.  
  101. <div id="primary" <?php tools::primary_class( $post_id , 'page' ); ?>>
  102.  
  103. <div id="content" role="main">
  104.  
  105. <?php
  106.  
  107. if( (int)options::get_value( 'general' , 'my_posts_page' ) == $post_id ){
  108.  
  109. ?>
  110.  
  111. <div class="w_<?php echo layout::length( $post_id , 'page' ); ?> my-posts"><!--add class my posts-->
  112.  
  113. <div class="list">
  114.  
  115. <?php post::my_posts( get_current_user_id() ); ?>
  116.  
  117. </div>
  118.  
  119. </div>
  120.  
  121. <?php
  122.  
  123. }else{
  124.  
  125. ?>
  126.  
  127. <div <?php tools::content_class( $post_id , 'page' , '' , false ); ?>>
  128.  
  129.  
  130.  
  131. <?php
  132.  
  133. if( $post_id == options::get_value( 'upload' , 'post_item_page' ) ){
  134.  
  135. get_template_part( 'post_item' );
  136.  
  137. }elseif( $post_id == options::get_value( 'general' , 'user_profile_page' ) ){
  138.  
  139. get_template_part( 'user_profile' );
  140.  
  141. }else{
  142.  
  143.  
  144.  
  145. ?>
  146.  
  147. <!-- post -->
  148.  
  149. <article id="post-<?php the_ID(); ?>" <?php post_class( 'post' , $post -> ID ); ?>>
  150.  
  151.  
  152.  
  153. <!-- header -->
  154.  
  155. <?php
  156.  
  157. $template = 'page';
  158.  
  159. $attr = tools::login_attr( $post -> ID , 'nsfw mosaic-overlay' , get_permalink( $post -> ID ) );
  160.  
  161. $size = 'tmedium';
  162.  
  163. $s = image::asize( image::size( $post->ID , $template , $size ) );
  164.  
  165.  
  166.  
  167. if( options::logic( 'general' , 'enb_featured' ) ){
  168.  
  169. if ( has_post_thumbnail( $post -> ID ) && get_post_format( $post -> ID ) != 'video' ) {
  170.  
  171. $src = image::thumbnail( $post -> ID , $template , $size );
  172.  
  173. $caption = image::caption( $post -> ID );
  174.  
  175. ?>
  176.  
  177. <!-- thumbnail -->
  178.  
  179. <header class="entry-header">
  180.  
  181. <div class="featimg">
  182.  
  183. <div class="img">
  184.  
  185. <?php echo '<img src="' . $src[0] . '" alt="' . $caption . '" >'; ?>
  186.  
  187. </div>
  188.  
  189. </div>
  190.  
  191. </header>
  192.  
  193. <?php
  194.  
  195. }
  196.  
  197. }
  198.  
  199. ?>
  200.  
  201.  
  202.  
  203. <!-- content -->
  204.  
  205. <div class="entry-content">
  206.  
  207. <div class="b_text">
  208.  
  209. <?php the_content(); ?>
  210.  
  211. </div>
  212.  
  213.  
  214.  
  215. <?php
  216.  
  217. global $post;
  218.  
  219. $args = array( 'numberposts' => 20, 'offset'=> 0, 'category' => 202 );
  220.  
  221. $myposts = get_posts( $args );
  222.  
  223. foreach( $myposts as $post ) : setup_postdata($post); ?>
  224.  
  225.  
  226.  
  227. <div id="contestant">
  228.  
  229. <div style="margin-top: 130px; margin-left: 150px; z-index: 10; position: absolute">
  230.  
  231. <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>
  232.  
  233.  
  234.  
  235. <?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
  236.  
  237. <div style="clear: both"></div>
  238.  
  239. <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
  240.  
  241. <div style="clear: both"></div>
  242.  
  243.  
  244.  
  245. <?php the_content ?>
  246.  
  247. </div>
  248.  
  249. <?php endforeach; ?>
  250.  
  251. </div>
  252.  
  253.  
  254.  
  255. </div>
  256.  
  257.  
  258.  
  259. <!-- footer -->
  260.  
  261. <footer class="entry-footer">
  262.  
  263. <div class="share">
  264.  
  265. <?php get_template_part('social-sharing'); ?>
  266.  
  267. </div>
  268.  
  269. <?php
  270.  
  271. if( strlen( options::get_value( 'advertisement' , 'content' ) ) > 0 ){
  272.  
  273. ?>
  274.  
  275. <div class="cosmo-ads zone-2">
  276.  
  277. <?php echo options::get_value( 'advertisement' , 'content' ); ?>
  278.  
  279. </div>
  280.  
  281. <?php
  282.  
  283. }
  284.  
  285. ?>
  286.  
  287. </footer>
  288.  
  289. </article>
  290.  
  291.  
  292.  
  293. <p class="delimiter blank">&nbsp;</p>
  294.  
  295.  
  296.  
  297. <?php
  298.  
  299. /* comments */
  300.  
  301. if( comments_open() ){
  302.  
  303. if( options::logic( 'general' , 'fb_comments' ) ){
  304.  
  305. ?>
  306.  
  307. <div id="comments">
  308.  
  309. <h3 id="reply-title"><?php _e( 'Leave a reply' , 'cosmotheme' ); ?></h3>
  310.  
  311. <p class="delimiter">&nbsp;</p>
  312.  
  313. <fb:comments href="<?php the_permalink(); ?>" num_posts="5" width="620" height="120" reverse="true"></fb:comments>
  314.  
  315. </div>
  316.  
  317. <?php
  318.  
  319. }else{
  320.  
  321. comments_template( '', true );
  322.  
  323. }
  324.  
  325. }
  326.  
  327. }
  328.  
  329. ?>
  330.  
  331. </div>
  332.  
  333. <?php
  334.  
  335. }
  336.  
  337. ?>
  338.  
  339. </div>
  340.  
  341. </div>
  342.  
  343.  
  344.  
  345. <!-- right sidebar -->
  346.  
  347. <?php layout::side( 'right' , $post_id , 'page' ); ?>
  348.  
  349. </div>
  350.  
  351. <?php
  352.  
  353. }
  354.  
  355. ?>
  356.  
  357. </div>
  358.  
  359. <?php get_footer(); ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.