iLoveIt Wordpress主题FB照片竞赛页面模板

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iLoveIt Wordpress主题FB照片竞赛页面模板相关的知识,希望对你有一定的参考价值。

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.

  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(); ?>

以上是关于iLoveIt Wordpress主题FB照片竞赛页面模板的主要内容,如果未能解决你的问题,请参考以下文章

wordpress 照片墙 是如何实现的

wordpress制作照片瀑布流的效果,如何实现?

wordpress 页面布局乱了

如何在 Wordpress 的标题中添加图像 [关闭]

在 FB 的最新 apk 上分享照片

像 FB 封面照片一样在 UIImageView 上调整图像