Forum Bahasa Indonesia

nambah timthumb (3 posts)

  1. alief
    Anggota
    Posted 8 bulan ago #

    aku mencoba menambahkan fungsi timthumb pada template.
    akum ngambil kode seperti berikut
    ` <?php // This will show the image and link the image to the post. Alter the width and height (in both places) to your needs. ?>

    <?php if ( get_post_meta($post->ID, 'thumb', true) ) { ?>
    <div class="postthumb">
    " rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&h=150&w=150&zc=1" alt="<?php the_title(); ?>" width="150" height="150" />
    </div>
    <?php } ?>`
    masalahnya dengan pemakaian kode tersebut, tumbnail hanya akan muncul bila kita memasukan kata kunci "thumb" pada Custom Fields.
    yang aku mau bila kita tidak memasukan kata kunci tersebut ada gambar default yang akan muncul sebagai ganti. kode apa ya yang harus aku tambahkan??

    makasih bantuannya....

  2. poer
    Anggota
    Posted 8 bulan ago #

    tambahin else aja,

    <?php if ( get_post_meta($post->ID, 'thumb', true) ) { ?>
    kode ada thumb disini
    <?php } else { ?>
    kode defaultnya disini
    <?php } ?>

    bisa juga di kasih if else setelah

    /scripts/timthumb.php?src=<?php if-nya disini ?>

    dan hilangkan if yg di luarnya.

  3. alief
    Anggota
    Posted 8 bulan ago #

    siiip, makasih gan....

Balas

Anda harus log masuk untuk mengirim tulisan.

About this Topic