Memunculkan Konten WordPress Dengan Batas Jumlah Karakter Tertentu

Written by Fikri Rasyid

Secara default, ada dua cara memunculkan konten di WordPress:

  1. the_content() : Memunculkan semua konten ATAU memunculkan konten hingga batas tag <!--more--> yang ditentukan secara manual oleh author.
  2. the_excerpt() : Memunculkan 55 kata awal dari konten ATAU custom content yang dimasukkan ke boks excerpt di halaman editor

Masalahnya, bagaimana jika pada theme anda, anda hendak menampilkan, let’s say hanya 20 kata dari konten dan author tidak tahu menahu mengenai mekamisme tag <!--more-->?

C.Bavota menulis tutorial / snippet yang memecahkan masalah ini:

Excerpt or Content Word Limit in WordPress: Redux

Copy & paste snippet di file functions.php theme anda, lalu di loop halaman yang anda kehendaki, alih-alih menuliskan

<?php the_excerpt(); ?>

Tuliskan

<?php echo excerpt(20); ?>

That will do the work ;)

About The Author

Fikri Rasyid - I speak HTML + CSS + jQuery, breath in world wide WordPress-land, co-founded WPNest and currently pursuing my bachelor degree majoring English Education at Indonesia University of Education. Google my name for more information about me.

Connect & Subscribe

Keep in touch and get my latest content trough:

Categories

Post Info

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>