- Isi keywords di StupidPie/keywords.txt
- Upload dan aktifkan pluginnya
- Kopi paste kode
<?php echo spp(get_search_query());?>
taruh pada file search.php themes wordpress Anda. Masukkan kode diatas sebelum code
if have_post();
- Kopi paste kode
[spp_random_terms count=3]
di sidebar wordpress, widget text.
- Secara default kode
<?php echo spp(get_search_query());?>
memanggil template default.html check pada folder (StupidPie\templates\default.html)
Contoh di atas adalah contoh penggunaan tingkat dasar. StupidPie sendiri sebenarnya bisa memakai 3 parameter saat dipanggil. Secara default, spp memanggil parameter keyword, template dan hack:
<?php
$keyword = get_search_query();
$template = 'default.html';
$hack = '';
echo spp($keyword, $template, $hack);
// bisa disingkat echo spp($keyword);
?>
Keyword
Keyword adalah satu-satunya parameter yang wajib diisi. Karena beda tempat beda cara dapatkan keywordnya. Sebagai contoh, di single.php keyword bisa didapatkan dengan cara:
$keyword = single_post_title( '', false );
Kalau di halaman search.php:
$keyword = get_search_query();
Template
Template adalah tempat kita mengatur tampilan hasil ambil data. Lokasinya di folder StupidPie/templates. Kita bisa membuat template sendiri atau memodifikasi dari yang sudah ada. Template StupidPie memakai standar h2o template engine jadi kalau ada waktu untuk mempelajari syntax templatenya, bisa melihat dokumentasi lebih jelas untuk
template h2o.
Untuk memanggil template, bisa dimasukkan ke parameter kedua. Misal:
<?php
$keyword = get_search_query();
$template = 'video.html';
$hack = '';
echo spp($keyword, $template, $hack);
?>
Hack
Hack adalah parameter ketiga yang jarang dipakai namun cukup keren. Dengan memanfaatkan hack, kita bisa membuat hampir semua jenis AGC. Misal, pdf, ppt, doc, amazon, ehow, dll. Fungsinya sendiri semacam filter. Sebagai contoh:
<?php
$keyword = get_search_query();
$template = 'wiki.html'; // semisal kita bikin template sendiri untuk wikipedia
$hack = 'site:en.wikipedia.org'; // hack ini akan menampilkan konten HANYA dari
en.wikipedia.org
echo spp($keyword, $template, $hack);
?>
Contoh lain untuk pdf search engine:
<?php
$keyword = get_search_query();
$template = 'pdf.html'; // semisal kita bikin template sendiri untuk pdf
$hack = 'filetype:pdf'; // hack ini akan menampilkan konten HANYA yang
berakhiran .pdf
echo spp($keyword, $template, $hack);
?>
- Jika ingin memakai permalink statis seperti domain.com/tag/keyword1-keyword2
Buka file
/Stupidpie/templates/widget.html lihat kode:
<a hreff="{{ term.term | build_permalink_for 'tag' }}">{{ term.term }}</a>
Pastikan setelah build_permalink_for nilainya 'tag'
- Jika ingin memakai permalink random seperti domain.com/abcdefg/keyword1-keyword2
Buka file
/Stupidpie/templates/widget.html lihat kode:
<a hreff="{{ term.term | build_permalink_for 'random' }}">{{ term.term }}</a>
Pastikan setelah build_permalink_for nilainya 'random'
- Jika ingin memakai permalink dinamis seperti domain.com/keyword1/keyword1-keyword2-keyword3
Buka file
/Stupidpie/templates/widget.html lihat kode
<a hreff="{{ term.term | build_permalink_for 'first_word' }}">{{ term.term }}</a>
Pastikan setelah build_permalink_for nilainya 'first_word'
Tutorial StupidPie