SHARE
TWEET

Tambah Caption Featured Image WP Flexithemes

pustakakoran May 18th, 2017 (edited) 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Buka post-single.php:
  2.  
  3. 1. Cari kode thumbnail:
  4.             <?php
  5.                 if(has_post_thumbnail())  {
  6.                     the_post_thumbnail(
  7.                         array($theme->get_option('featured_image_width_single'), $theme->get_option('featured_image_height_single')),
  8.                         array("class" => $theme->get_option('featured_image_position_single') . " featured_image")
  9.                     );
  10.                 }
  11.             ?>
  12.  
  13. 2. Ganti dengan kode berikut:
  14. <div class="wp-caption">
  15. <?php the_post_thumbnail(''); ?> <!-- This displays the featured image -->
  16. <?php if ( $caption = get_post( get_post_thumbnail_id() )->post_excerpt ) : ?>
  17.     <p class="wp-caption-text"><?php echo $caption; ?></p>
  18. <?php endif; ?><!-- This displays the caption below the featured image -->
  19. </div>
  20.  
  21. 3. Tambahkan kode berikut di CSS:
  22. .wp-caption {
  23.     background: #eee;
  24.     border: 1px solid #ddd;
  25.     text-align: center;
  26.     padding: 4px 4px 0 4px;
  27.     margin: 10px;
  28.     /* optional rounded corners for browsers that support it */
  29.     -moz-border-radius: 3px;
  30.     -khtml-border-radius: 3px;
  31.     -webkit-border-radius: 3px;
  32.     border-radius: 3px;
  33. }
  34.  
  35. .wp-caption img {
  36.     margin: 0;
  37.     padding: 0;
  38.     border: 0 none;
  39. }
  40.  
  41. .wp-caption p.wp-caption-text {
  42.     font-size: 11px;
  43.     line-height: 17px;
  44.     padding: 0 4px 5px;
  45.     margin: 0;
  46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top