Belajar Membuat Theme WordPress Part 5 ~ 8

Posted by welcome to the nightmare On 04.02 0 komentar


Belajar Membuat Theme WordPress Part 5 ~ 8

PART 5

mari kita lanjutkan pembelajaran kita pada pembahasan pembuatan tema wordpress.

Yang langsung nyantol di link ini, nih ane kasih part part sebelum mulai beranjak untuk membaca part 5 ini. silakan di pelajari dan di komentari
:D


Kemaren kita udah buat file sidebar.php, dan berhubung sekarang waktu ane sangat sangat singkat banget, jadi kita mulai dengan hal file yang simple dulu kali ye…

Oke yang sekarang akan kita bahas adalah membuat file comments.php

Berhubung ane sendiri sampe sekarang masih agak bingung tentang costumasi file comments.php jadi ane kasih mentahnya aja untuk kalian copas di file comments.php yang sebelumnya telah kita buat.

Silakan pastekan function ini di comments.php

<?php // Do not delete these lines
if (‘comments.php’ == basename($_SERVER['SCRIPT_FILENAME']))
die (‘Please do not load this page directly. Thanks!’);
if (!empty($post->post_password)) { // if there’s a password
if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn’t match the cookie
?>
<p>This post is password protected. Enter the password to view comments.</p>
<?php
return;
}
}
/* This variable is for alternating comment background */
$oddcomment = ”;
?>
<!– You can start editing here. –>
<?php if ($comments) : ?>
<h2 id=”comments”>Comments</h2>
<div>
<?php wp_list_comments2(); ?>
</div>
<?php else : // this is displayed if there are no comments so far ?>
<?php if (‘open’ == $post->comment_status) : ?>
<!– If comments are open, but there are no comments. –>
<?php else : // comments are closed ?>
<!– If comments are closed. –>
<p>Comments are closed.</p>
<?php endif; ?>
<?php endif; ?>
<?php if (‘open’ == $post->comment_status) : ?>
<div id=”respond”>
<h3 id=”respond_title”>Post a comment</h3>
<div>
<small><?php cancel_comment_reply_link(); ?></small>
</div>
<?php if ( get_option(‘comment_registration’) && !$user_ID ) : ?>
<p>You must be <a href=”<?php echo get_option(‘siteurl’); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>”>logged in</a> to post a comment.</p>
<?php else : ?>
<form action=”<?php echo get_option(‘siteurl’); ?>/wp-comments-post.php” method=”post” id=”commentform”>
<div>
<?php theme_google_300_ads_show(); ?>
</div>
<?php if ( $user_ID ) : ?>
<p>Logged in as <a href=”<?php echo get_option(‘siteurl’); ?>/wp-admin/profile.php”><?php echo $user_identity; ?></a>. <a href=”<?php echo wp_logout_url(get_permalink()); ?>” title=”Log out of this account”>Log out &raquo;</a></p>
<?php else : ?>
<p><input type=”text” name=”author” id=”author” value=”<?php echo $comment_author; ?>” size=”22″ tabindex=”1″ <?php if ($req) echo “aria-required=’true’”; ?> />
<label for=”author”><small>Name <?php if ($req) echo “(required)”; ?></small></label></p>
<p><input type=”text” name=”email” id=”email” value=”<?php echo $comment_author_email; ?>” size=”22″ tabindex=”2″ <?php if ($req) echo “aria-required=’true’”; ?> />
<label for=”email”><small>Mail (will not be published) <?php if ($req) echo “(required)”; ?></small></label></p>
<p><input type=”text” name=”url” id=”url” value=”<?php echo $comment_author_url; ?>” size=”22″ tabindex=”3″ />
<label for=”url”><small>Website</small></label></p>
<?php endif; ?>
<!–<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>–>
<p><textarea name=”comment” id=”comment” cols=”100%” rows=”10″ tabindex=”4″></textarea></p>
<p><input name=”submit” type=”image” src=”<?php bloginfo(‘template_url’)?>/images/comm_sub.gif” id=”submit” tabindex=”5″ value=”Submit Comment” />
<?php comment_id_fields(); ?>
</p>
<?php do_action(‘comment_form’, $post->ID); ?>
</form>
<?php endif; // If registration required and not logged in ?>
</div>
<?php endif; // if you delete this the sky will fall on your head ?>

Dari pengalaman ane selama ini mengostumasi file comments.php, ane hanya mengetahui beberapa dari ratusan bahkan ribuat trik untuk membuat menarik comments kalian…

Kalian bisa mempercantik tag tag html nya dengan mengcostumasinya di style.css

PART 6


Yo yo yo. selamat malam kawan semuanya…. mari kita lanjutkan pembelajaran kita pada pembahasan pembuatan tema wordpress.

Ga kerasa sekarang itu udah memasuki tuto yang part 6,

Yang sekarang akan kita bahas adalah cara membuat file single.php, oh iye, tutor ini ane dah susun mulai dari depan hingga belakang secara berurutan, seperti pada part 1 kita membahas membuat header, dan footer pada part 2, dilanjutkan dengan index pada part 3, disusul oleh sidebar pada part 4, dan comments pada part 5, jadi menurut hemat saya, maka selanjutnya adalah single, so lets start….
pada dasarnya, single.php itu sama dengan index.php hanya saja ada beberapa tambahan pada page single. seperti komentar, similiar post, etc.

Jadi untuk membuat single.php kita buka dulu file index.php
Dan copas isinya ke single.php….



Berikut adalah isi dari index.php renewal yang udah di refisi pada part 4,

<?php get_header()?>
<section id=”content”><!– #content –>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<h2><a href=”<?php the_permalink() ?>” ><?php the_title(); ?></a></h2>
<p><img src=”<?php bloginfo(‘template_directory’); ?>/images/orangebutterfly.png” alt=”” />
<?php the_content(‘Read more &raquo;’); ?></p>
</article>
<?php endwhile; ?>
<?php endif; ?>

</section><!– end of #content –>
<?php get_sidebar(); ?><?php get_footer();?>

Nah sekarang tambah kan code pemanggil comment
Berikut code nya…

<?php comments_template(); ?>
Letakan sebelum endwhile, maka hasil akhirnya seperti ini…
<?php get_header()?>
<section id=”content”><!– #content –>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<h2><a href=”<?php the_permalink() ?>” ><?php the_title(); ?></a></h2>
<p><img src=”<?php bloginfo(‘template_directory’); ?>/images/orangebutterfly.png” alt=”” />
<?php the_content(‘Read more &raquo;’); ?></p>
</article>
<?php comments_template(); ?>
<?php endwhile; ?>
<?php endif; ?>

</section><!– end of #content –>
<?php get_sidebar(); ?><?php get_footer();?>

Save code diatas dengan nama single.php,

Mudah kan.. oke sekarang mah belajarnye pendek pendek aje dulu ye.. cz takut muntah klo di jejelin bejibun code dalam sekali lahap, Pelan pelan aje ye, supaya tar kalian pada bisa dan berkarya dengan ilmu,,

NB : keep learning and join us @ forum.binushacke.net

PART 7

 setelah kemaren kita buat file single.php sekarang kita akan membahas page.php




Sebenernye sama aja dengan single.php cuma page.php ini akan didipake sebagai default page yang kita buat.

Sekarang kita buka lagi file single.php nya.. dan copy semua source yang ada, copas ke file page.php
Maka file page.php akan menjadi seperti ini
<?php get_header()?>
<section id=”content”><!– #content –>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<h2><a href=”<?php the_permalink() ?>” ><?php the_title(); ?></a></h2>
<p><img src=”<?php bloginfo(‘template_directory’); ?>/images/orangebutterfly.png” alt=”” />
<?php the_content(‘Read more &raquo;’); ?></p>
</article>
<?php comments_template(); ?>
<?php endwhile; ?>
<?php endif; ?>
</section><!– end of #content –>
<?php get_sidebar(); ?><?php get_footer();?>
Ada satu lagi trik di file page.php ini. ane nemu trik ini setelah beberapa waktu lalu ane mau buat page galery di blog ane, tapi rasanya canggung klo pake template page bawaan tema. makanya ane cari sumber lain dan ga jauh jauh.. ketemunye di instalan wordpress juga, tepatnye di tema bawaan wordpress.. nah hal yang perlu kalian tambahkan untuk membuat page yang kalian ingin kan dan pastinya beda dari page.php yang ada. silakan kalian modifikasi sebagus mungkin file page.php nya. setelah itu save as, ubah namanya terserah kalian, disini saya kasih contoh galery.php nah setelah itu kalian tambah kan code ini tepat di atas

<?php get_header();?>

Berikut codenya

<?php /*
Template Name: Galery
*/ ?>
Nah jadinya seperti ini

<?php /*
Template Name: Galery
*/ ?>

<?php get_header()?>
<section id=”content”><!– #content –>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article>
<h2><a href=”<?php the_permalink() ?>” ><?php the_title(); ?></a></h2>
<p><img src=”<?php bloginfo(‘template_directory’); ?>/images/orangebutterfly.png” alt=”” />
<?php the_content(‘Read more &raquo;’); ?></p>
</article>
<?php comments_template(); ?>
<?php endwhile; ?>
<?php endif; ?>
</section><!– end of #content –>
<?php get_sidebar(); ?><?php get_footer();?>

Oke untuk kostumasinya saya akan tampilkan jika tutorial ini sudah selesai dan tema hasil buatan kita ..
So have a nice day and nice day

PART 8


Seperti yang sudah ane janjiin dulu di pagenya B|H di facebook bahwa ane akan bahas tentang functions.php di wordpress, nah pertemuan sekarang ane akan sedikit mengulas tentang functions.php, pada dasarnya functions.php adalah file yang berisi perintah tambahan untuk blog kita. dan disini kita bisa melakukan segala hal untuk blog kita. bisa dibilang ini adalah nyawa ketiga blog kita setelah hosting dan theme…
.


So lets begin

Completely remove the version number from pages and feeds

// remove version info from head and feeds
function complete_version_removal() {
return ”;
}
add_filter(‘the_generator’, ‘complete_version_removal’);
Customize the admin footer message
// customize admin footer text
function custom_admin_footer() {
echo ‘Website Design by Monzilla Media’;
}
add_filter(‘admin_footer_text’, ‘custom_admin_footer’);
Enable delete and spam links for comments
// spam & delete links for all versions of wordpress
function delete_comment_link($id) {
if (current_user_can(‘edit_post’)) {
echo ‘| del ‘;
echo ‘| spam’;
}
}

dan tambah kan ini di cooments loop nya

Disable all WordPress feeds
// disable all feeds
function fb_disable_feed() {
wp_die(__(‘

Feed not available, please visit our Home Page!

‘));
}
add_action(‘do_feed’, ‘fb_disable_feed’, 1);
add_action(‘do_feed_rdf’, ‘fb_disable_feed’, 1);
add_action(‘do_feed_rss’, ‘fb_disable_feed’, 1);
add_action(‘do_feed_rss2′, ‘fb_disable_feed’, 1);
add_action(‘do_feed_atom’, ‘fb_disable_feed’, 1);
Add feed links to header
// add feed links to header
if (function_exists(‘automatic_feed_links’)) {
automatic_feed_links();
} else {
return;
}
Enable threaded comments
// enable threaded comments
function enable_threaded_comments(){
if (!is_admin()) {
if (is_singular() AND comments_open() AND (get_option(‘thread_comments’) == 1))
wp_enqueue_script(‘comment-reply’);
}
}
add_action(‘get_header’, ‘enable_threaded_comments’);
Remove unwanted crap from the head section
// remove junk from head
remove_action(‘wp_head’, ‘rsd_link’);
remove_action(‘wp_head’, ‘wp_generator’);
remove_action(‘wp_head’, ‘feed_links’, 2);
remove_action(‘wp_head’, ‘index_rel_link’);
remove_action(‘wp_head’, ‘wlwmanifest_link’);
remove_action(‘wp_head’, ‘feed_links_extra’, 3);
remove_action(‘wp_head’, ‘start_post_rel_link’, 10, 0);
remove_action(‘wp_head’, ‘parent_post_rel_link’, 10, 0);
remove_action(‘wp_head’, ‘adjacent_posts_rel_link’, 10, 0);
Add a different favicon for your blog’s Admin area
// add a favicon for your admin
function admin_favicon() {
echo ”;
}
add_action(‘admin_head’, ‘admin_favicon’);
Custom Admin Login logo
// custom admin login logo
function custom_login_logo() {
echo ‘
h1 a { background-image: url(‘.get_bloginfo(‘template_directory’).’/images/custom-login-logo.png) !important; }
‘;
}
add_action(‘login_head’, ‘custom_login_logo’);
Disable unused widget areas
// disable all widget areas
function disable_all_widgets($sidebars_widgets) {
//if (is_home())
$sidebars_widgets = array(false);
return $sidebars_widgets;
}
add_filter(‘sidebars_widgets’, ‘disable_all_widgets’);
Kill the WordPress update nag
// kill the admin nag
if (!current_user_can(‘edit_users’)) {
add_action(‘init’, create_function(‘$a’, “remove_action(‘init’, ‘wp_version_check’);”), 2);
add_filter(‘pre_option_update_core’, create_function(‘$a’, “return null;”));
}
Sekarang tinggal di masukan kepada file functions.php dan walah,, jadilah tema yang selama ini jadi tutorial kita.. untuk demo nya menyusul ya, cz belum ane susun…

UPDATE Versi E-Book!

Buat yang menunggu versi ebook nya ini suadah saya buat kan, jadi silakan di dikmati. Dan untuk versi videonya sedang di garap.. so sabar
:)
Dowload di Link Berikut untuk Ebooknya:







Categories: ,

0 Response for the "Belajar Membuat Theme WordPress Part 5 ~ 8"

Posting Komentar

Sponsors