Untuk Anda yang lagi pengen utak atik situs WordPress Anda bisa simpan kode WP berikut ini.
Terutama kali buat Anda yang masih belajar-belajar, tentu saja kode tag WP ini penting buat Anda simpan.
Contoh penggunaan misal ada kasus seperti ini:
Anda pengen tahu gimana cara membuat blog card yang menampilkan:
Gimana cara'a?
Copy dulu kode dibawah ini sebagai bahan contekan kalau suatu-waktu Anda butuh. Untuk cara buatnya lihat di kode snippet dibawah ini lagi.
<?php the_time() ?> Displays the time of the current post <?php the_date() ?> Displays the date of a post or set of posts <?php the_title(); ?> Displays or returns the title of the current post <?php the_excerpt(); ?> Displays or returns the excerpt of the current post <?php the_permalink() ?> Displays the URL for the permalink <?php the_category() ?> Displays the category of a post <?php the_author(); ?> Displays the author of the post <?php the_ID(); ?> Displays the numeric ID of the current post <?php wp_list_pages(); ?> Displays all the pages <?php wp_tag_cloud(); ?> Displays a tag cloud <?php wp_list_cats(); ?> Displays the categories <?php get_calendar(); ?> Displays the calendar <?php wp_get_archives() ?> Displays a date-based archives list <?php posts_nav_link(); ?> Displays Previous page and Next Page links <?php next_post_link() ?> Displays Newer Posts link <?php previous_post_link() ?> Displays previous link <?php get_stylesheet_directory_uri(); ?> Gets Stylesheet Directory
Ini cara membuat blog card yang menampilkan:
- Judul Post
- Featured Image
- Excerpt
- Tombol read more
Didalam sebuah div
<!-- ini gk usah dimasukan <?php the_title(); ?> Menampilkan judul post <?php the_excerpt(); ?> Menampilkan excerpt post <?php the_permalink() ?> Menampilkan URL post <?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID, 'thumbnail') ); ?> menampilkan featured image dengan ukuran thumbnail (ganti full kalau mau ukuran lebih besar) --> <!-- Contoh --> <div class="bebas> <div class="card-top"> <?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID, 'thumbnail') ); ?> </div> <div class="card-bottom"< <span class="eg-judul"><h2><?php the_title(); ?></h2></span> <span class="eg-excerpt"><?php the_excerpt(); ?></span> <button><a href="<?php the_permalink() ?>">Readmore</a></button> </div> </div>