• Selamatt daerah waktu setempat…. 🙂 agan2 dan para masta dan moderator:….

    gmna gan cara menampilkan image thumbnail pada archive.php jadi pas kita pilih atau search nntinya terindex ada imagenya biar menarik.. untuk sementara punya ane seperti ini http://ramiedarussalam.com/category/budidaya-ramie/ itu udah muncul textnya sesuai kategori tapi belum ada imagenya.. nahh cara bikin scriptnya gmna gan.. boleh di ambil dari image pertama atau dari featured images… tehx gannn….

Melihat 15 balasan - 1 sampai 15 (dari total 19)
  • coba pake fungsi tambahan begini:

    function get_post_image() {
      global $post, $posts;
      $first_img = '';
      ob_start();
      ob_end_clean();
      $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
      $first_img = $matches [1] [0];
      if(empty($first_img)){ //Defines a default image
      	$img_dir = get_bloginfo('template_directory');
        $first_img = $img_dir . '/images/post-default.jpg';
      }
      return $first_img;
    }

    Pencetus Utas ugie

    (@apel-ijo)

    tengkyu gann (kegirangan sambil jingkrak2..)…. ane ke TKP langsung..

    Pencetus Utas ugie

    (@apel-ijo)

    di letakannya sebelum

    <?php the_excerpt() ?>

    bukan gan?.. belum bisa tampil gan..

    Pencetus Utas ugie

    (@apel-ijo)

    sourcenya seperti ini gan

    <?php get_header(); ?>

    <!–<div id=”single”><div class=”logg”><?php bloginfo(‘description’); ?></div></div>–>

    <div id=”page”>
    <div id=”leftsidebar”>
    <?php
    // Widget Kiri
    if (!function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(1)) :
    endif;
    ?>
    </div>

    <div id=”content” class=”narrowcolumn”>

    <?php if (have_posts()) : ?>

    <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>

    <?php /* If this is a category archive */ if (is_category()) { ?>

    <h2 class=”pagetitle”>Kategori dari ‘<?php echo single_cat_title(); ?>'</h2>

    <?php /* If this is a daily archive */ } elseif (is_day()) { ?>

    <h2 class=”pagetitle”>Arsip untuk<?php the_time(‘F jS, Y’); ?></h2>

    <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>

    <h2 class=”pagetitle”>Arsip untuk <?php the_time(‘F, Y’); ?></h2>

    <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>

    <h2 class=”pagetitle”>Arsip untuk <?php the_time(‘Y’); ?></h2>

    <?php /* If this is a search */ } elseif (is_search()) { ?>

    <h2 class=”pagetitle”>Hasil pencarian</h2>

    <?php /* If this is an author archive */ } elseif (is_author()) { ?>

    <h2 class=”pagetitle”>Author Archive</h2>

    <?php /* If this is a paged archive */ } elseif (isset($_GET[‘paged’]) && !empty($_GET[‘paged’])) { ?>

    <h2 class=”pagetitle”>≡ Blog Archives</h2>

    <?php } ?>

    <div class=”navigation”>

    <div class=”alignleft”><?php posts_nav_link(”,”,’« Previous Entries’) ?></div>

    <div class=”alignright”><?php posts_nav_link(”,’Next Entries »’,”) ?></div>

    </div>

    <?php while (have_posts()) : the_post(); ?>

    <div class=”post”>

    <h3 id=”post-<?php the_ID(); ?>”>≡ ” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></h3>

    <div class=”entry”>

    <?php the_excerpt() ?>

    </div>
    </br> </br>
    <small><?php the_time(‘F jS, Y’) ?>Topic: <?php the_category(‘, ‘) ?> <?php if(function_exists(‘the_tags’)) {$my_tags = get_the_tags();if ( $my_tags != “” ){ the_tags(‘Tags: ‘, ‘, ‘, ”); } else {echo “Tags: None”;} }?>

    <?php if(function_exists(‘UTW_ShowTagsForCurrentPost’)) { echo ‘Tags: ‘;UTW_ShowTagsForCurrentPost(“commalist”);echo ”; } ?></small>

    <p class=”postmetadata”>Posted in <?php the_category(‘, ‘) ?> | <?php edit_post_link(‘Edit’,”,’|‘); ?> <?php comments_popup_link(‘No Comments »’, ‘1 Comment »’, ‘% Comments »’); ?></p>

    <!–

    <?php trackback_rdf(); ?>

    –>

    </div>

    <?php endwhile; ?>

    <div class=”navigation”>

    <div class=”alignleft”><?php posts_nav_link(”,”,’« Previous Entries’) ?></div>

    <div class=”alignright”><?php posts_nav_link(”,’Next Entries »’,”) ?></div>

    </div>

    <?php else : ?>

    <h2 class=”center”>Not Found</h2>

    <?php include (TEMPLATEPATH . ‘/searchform.php’); ?>

    <?php endif; ?>

    </div>

    <div id=”rightsidebar”>
    <?php
    // Widget Kanan
    if (!function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(2)) :
    endif;
    ?>
    </div>

    <?php get_footer(); ?>
    </div>

    pemakaiannya <img src=”<?php echo get_post_image();>”>

    Pencetus Utas ugie

    (@apel-ijo)

    masta… ane masih belum mengerti penempatan codenya gan….
    mohon pecerahaannya..

    coba sisipkan sebelum <?php the_excerpt() ?>, jadi :

    ..........
    <div class="entry">
    <div class="post-img">
    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo get_post_image();?>" width="200" height="200" alt="<?php the_title(); ?>" /></a>
    </div>
    <?php the_excerpt() ?>
    </div>
    ............

    Pencetus Utas ugie

    (@apel-ijo)

    ga bibsa gan malah jadi ngeblank/ga muncul… <?php the_excert() ?> malah jadi ga aktif….

    sudah ane tes gan, hasilnya bisa,
    asalkan images ada di ‘wp-content/upload/’ belum dipindah jad ‘static’
    coba dicek hasil copasnya.. jangan salah copas & penempatannya

    Pencetus Utas ugie

    (@apel-ijo)

    baik masta… tengkyou.. ane coba lagi..

    kalau ingin pake timthumb.php, jadi begini,
    ……….

    <div class="entry">
    <div class="post-img">
    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo get_bloginfo('template_url'); ?>/timthumb.php?src=<?php echo get_post_image();?>&w=150&h=200&zc=1" alt="<?php the_title(); ?>" /></a>
    </div>
    <?php the_excerpt() ?>
    </div>

    …………

    filenya bisa didownload di:
    http://code.google.com/p/timthumb/
    1. tempatkan file timthumb.php ke dalam folder tema yang dipakai
    2. buat bulder cache di dalam tema yang dipakai
    3. cmod 777 folder cache

    Pencetus Utas ugie

    (@apel-ijo)

    Pake cara yang pertama udah bisa gan… ternyata path-nya yang salah…. jadi ga tampil deh… 🙂 makasihhh banyak ya gann…

    waahh itu baru lagii ya gann… timthumb, itu buat apa gan?

    ane ada yang belum ngerti ama nomor 2. buat bulder cache, bulder cache itu apa ya gan? ane dah coba searching di google ga dapet jga..

    terus nomor 3. cmod 777 folder cache maksudnya gmna gan?

    mohon pencerahannya….

    Moderator Bogy Harseno

    (@bogyharseno-1)

    Sebenarnya WordPress telah dilengkapi dgn Featured Image 🙂

    untuk auto feature paka plugin apa Mas Bogi?
    cos kadang ribet, harus set feature, lebih mudah dengan select gambar pertama,
    apa lagi editornya ga pake admin di wp

    dah ada ternyata,
    http://wordpress.org/extend/plugins/auto-featured-image/
    tp belum tes, apakah hasilnya permanen atau ga

Melihat 15 balasan - 1 sampai 15 (dari total 19)
  • Topik ‘menampilkan image thumbnail pada archive.php’ tertutup untuk balasan baru.