Advertisement
pusatdata

WP: Memasang featured image di index.php/category.php

Aug 29th, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. CARA MEMBUAT FEATURED IMAGE WORDPRESS
  2.  
  3. PERTAMA:
  4. function.php:
  5. <?php
  6. add_theme_support( 'post-thumbnails' );
  7. set_post_thumbnail_size( 100, 100, true );
  8. ?>
  9.  
  10. KEDUA:
  11. Jika kode artikelnya masih: <?php the_content(); ?>
  12. ubah menjadi: <?php if (is_single()) { the_content(); } else { the_excerpt(); } ?>
  13. tujuannya: agar full HTML hanya muncul di halaman single saja. Sedangkan jika ada di home/index.php atau arsip/category.php, semua kode HTML dinonaktifkan dan hanya menampilkan ringkasannya saja.
  14.  
  15. KETIGA:
  16. index.php atau category.php:
  17. <?php if ( has_post_thumbnail() ) {
  18. the_post_thumbnail();
  19. } else {
  20. echo '<img src="http://i1147.photobucket.com/albums/o553/jonobones/thumbnaildefault.png" alt="'.get_the_title().'" class="wp-post-image"/>';
  21. } ?>
  22.  
  23. Letakkan sebelum kode tersebut sebelum kode artikel <?php if (is_single()) { the_content(); } else { the_excerpt(); } ?>
  24.  
  25. KEEMPAT:
  26. style.css:
  27. img.wp-post-image {
  28. float:left;
  29. margin-right:5px;
  30. width:100px;
  31. height:100px;
  32. padding:3px;
  33. border:solid 1px #cccccc; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement