11 Faydalı WordPress Fonksiyonu

WordPress, kişiselleştirilebilmesi açısından en çok tercih edilen blog yazılımları arasında yer alıyor. Açık kaynak kodlu olması nedeniyle yazılım üzerinde istediğimiz değişiklikleri kolay bir şekilde gerçekleştirebiliyoruz. Bu yazımızda temamızın function.php dosyası üzerinde yapacağımız değişiklikler ile blogumuzu kişiselleştirebileceğimiz bazı örneklere değineceğiz.
Başlıklar
- 1 1- Google Analytics Kodu Ekleme
- 2 2- Favicon Ekleme
- 3 3- WordPress Sürüm Numarasını Kaldırma
- 4 4- Yönetim Paneli Logosunu Değiştirme
- 5 5- Yönetim Paneli Footer Düzenleme
- 6 6- Yönetim Paneline Not Kutusu Ekleme
- 7 7- Değişken Copyright Tarihi
- 8 8- Profil Sayfasındaki Aim, Jabber, Yahoo Messenger Alanlarını Kaldırma
- 9 8- Profil Sayfasına Facebook ve Twitter Alanları Ekleme
- 10 9- Rss Beslemelerine Resim Ekleme
- 11 10- Özet Metin Karakter Sınırlama
- 12 11- Rss Beslemelerini Kapatma
1- Google Analytics Kodu Ekleme
<?php add_action('wp_footer', 'add_googleanalytics'); function add_googleanalytics() { ?> // Google Analytics Kodu <?php } ?>
2- Favicon Ekleme
// Favicon function blog_favicon() { echo ''; } add_action('wp_head', 'blog_favicon');
3- WordPress Sürüm Numarasını Kaldırma
function portalimiz_remove_version() { return ''; } add_filter('the_generator', 'portalimiz_remove_version');
4- Yönetim Paneli Logosunu Değiştirme
//yönetim paneli logosu add_action('admin_head', 'my_custom_logo'); function my_custom_logo() { echo ' '; }
function remove_footer_admin () { echo 'Fueled by WordPress | Düzenleme: Portalimiz.Com'; } add_filter('admin_footer_text', 'remove_footer_admin');
6- Yönetim Paneline Not Kutusu Ekleme
add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets'); function my_custom_dashboard_widgets() { global $wp_meta_boxes; wp_add_dashboard_widget('custom_help_widget', 'Theme Support', 'custom_dashboard_help'); } function custom_dashboard_help() { echo 'Bu düzenleme portalimiz.comtarafından yapılmıştır. Sorularınız için sayfasını kullanabilirsiniz.
'; }
7- Değişken Copyright Tarihi
function comicpress_copyright() { global $wpdb; $copyright_dates = $wpdb->get_results(" SELECT YEAR(min(post_date_gmt)) AS firstdate, YEAR(max(post_date_gmt)) AS lastdate FROM $wpdb->posts WHERE post_status = 'publish' "); $output = ''; if($copyright_dates) { $copyright = "© " . $copyright_dates[0]->firstdate; if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) { $copyright .= '-' . $copyright_dates[0]->lastdate; } $output = $copyright; } return $output; }
8- Profil Sayfasındaki Aim, Jabber, Yahoo Messenger Alanlarını Kaldırma
add_filter('user_contactmethods','hide_profile_fields',10,1); function hide_profile_fields( $contactmethods ) { unset($contactmethods['aim']); unset($contactmethods['jabber']); unset($contactmethods['yim']); return $contactmethods; }
8- Profil Sayfasına Facebook ve Twitter Alanları Ekleme
function my_new_contactmethods( $contactmethods ) { //Twitter $contactmethods['twitter'] = 'Twitter'; //Facebook $contactmethods['facebook'] = 'Facebook'; return $contactmethods; } add_filter('user_contactmethods','my_new_contactmethods',10,1);
9- Rss Beslemelerine Resim Ekleme
function rss_post_thumbnail($content) { global $post; if(has_post_thumbnail($post->ID)) { $content = '' . get_the_post_thumbnail($post->ID) . '
' . get_the_content(); } return $content; } add_filter('the_excerpt_rss', 'rss_post_thumbnail'); add_filter('the_content_feed', 'rss_post_thumbnail');
10- Özet Metin Karakter Sınırlama
function new_excerpt_length($length) { return 100; } add_filter('excerpt_length', 'new_excerpt_length');
11- Rss Beslemelerini Kapatma
function fb_disable_feed() { wp_die( __('Rss aktif değil anasayfa!') ); } 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);