En Çok Kullanılan WordPress Shortcodes

En Çok Kullanılan WordPress Shortcodes


Günümüzde esnek yapısı ve her türlü web sitesine uyum sağlaması nedeniyle en çok tercih edilen blog yazılımlarından biri olan WordPress’i dilediğiniz gibi kişiselleştirebilmenizin imkanı bulunuyor. Kullanım amacınıza uygun olarak dilerseniz yazılmış hazır eklentilerle dilerseniz kendinizin dosyalar üzerinde kodlarda değişiklik yaparak istediğiniz özelliğe sahip olabilirsiniz. Unutulmaması gereken durum yaptığınız değişiklikler ya da eklentiler ile sorgu sayınızın artmasına bu da sitenizin yavaş yüklenmesine neden olacağıdır. Bunun için sadece gerekli düzenlemeleri kullanmanızda fayda var. Bu yazımızda WordPress üzerinde eklenti kurmadan en çok kullanılan düzenlemeleri, WordPress’in shortcodes özelliğinden yararlanarak paylaşacağız.

[su_box title=”İlginizi Çekebilir”]

 

[/su_box]

* Aşağıda vereceğimiz örnekleri temanızın functions.php dosyasına eklemeniz gerekmektedir. Düzenleme yapmadan önce yedekleme yapmanız önerilir.

Google Adsense Reklamı Ekleme

Bu shortcode ile Google Adsense reklamlarını istediğiniz yerde gösterebilirsiniz. Bunun için kullanmanız gereken shortcode [adsensereklam]

function adsense_shortcode( $atts ) {
		extract(shortcode_atts(array(
        	'format' => '1',
        ), $atts));

        switch ($format) {
        		case 1 :
               		$ad = '<script type="text/javascript"><!-- 
        				google_ad_client = "pub-6928386133078345";
						/* 234x60, created 16/03/13 */
						google_ad_slot = "0834434562";
						google_ad_width = 234;
						google_ad_height = 60;
						//-->
						</script>
						<script type="text/javascript"
						src="https://pagead2.googlesyndication.com/pagead/show_ads.js">
						</script>';
				break;
		}
		return $ad;
}
add_shortcode('adsensereklam', 'adsense_shortcode');

* KOdda geçen Adsense kodunu kendi Adsense kodunuz ile değiştirin.

Benzer Yazılar

Sitenizde benzer yazıları göstermek için aşağıdaki kodu temanızın functions.php dosyasına girip benzer yazıların görünmesini istediğiniz yere [benzer_yazilar] kısa kodunu girin.

function related_posts_shortcode( $atts ) {
		extract(shortcode_atts(array(
	    'limit' => '5',
	), $atts));
    
    global $wpdb, $post, $table_prefix;
    
    if ($post->ID) {
			$retval = '
    '; // Get tags $tags = wp_get_post_tags($post->ID); $tagsarray = array(); foreach ($tags as $tag) { $tagsarray[] = $tag->term_id; } $tagslist = implode(',', $tagsarray); // Do the query $q = "SELECT p.*, count(tr.object_id) as count FROM $wpdb->term_taxonomy AS tt, $wpdb->term_relationships AS tr, $wpdb->posts AS p WHERE tt.taxonomy ='post_tag' AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tr.object_id = p.ID AND tt.term_id IN ($tagslist) AND p.ID != $post->ID AND p.post_status = 'publish' AND p.post_date_gmt < NOW() GROUP BY tr.object_id ORDER BY count DESC, p.post_date_gmt DESC LIMIT $limit;"; $related = $wpdb->get_results($q); if ( $related ) { foreach($related as $r) { $retval .= '
  • '.wptexturize($r->post_title).'
  • '; } else { $retval .= '
  • No related posts found
  • '; } $retval .= '
'; return $retval; } return; } add_shortcode('benzer_yazilar', 'related_posts_shortcode');

Paypal Bağış Kutusu

Sitenize Paypal Bağış Kutusu koymak isterseniz aşağıdaki kodu temanızın functions.php dosyasına girip bağış kutusunun görünmesini istediğiniz yere [bagis] kısa kodunu girin. Kodda geçen mail adresi kısmını Paypal adresiniz ile değiştirin.

function donate_shortcode( $atts, $content = null) {
	global $post;extract(shortcode_atts(array(
		'account' => 'mail adresi',
		'for' => $post->post_title,
		'onHover' => '',
	), $atts));
	if(empty($content)) $content='Bağış Yapın';
			return ''.$content.'';
}
add_shortcode('bagis', 'donate_shortcode');

Giriş Formu Ekleme

Sitenize giriş formu eklemek isteseniz aşağıdaki kodu temanızın functions.php dosyasına girip giriş formunun görünmesini istediğiniz yere [girisformu] kısa kodunu girin.

function devpress_login_form_shortcode() {
	if ( is_user_logged_in() )
		return '';

	return wp_login_form( array( 'echo' => true ) );
}

function devpress_add_shortcodes() {
	add_shortcode( 'girisformu', 'devpress_login_form_shortcode' );
}

add_action( 'init', 'devpress_add_shortcodes' );

Sadece Üyelerin Görebileceği İçerik

İçeriğinizi ziyaretçilere kapatmak isterseniz aşağıdaki kodu temanızın functions.php dosyasına girip gizlemek istediğiniz içeriğe [uye]Sadece Kayıtlı Kullanıcılar İçeriği Görebilir[/uye] kodunu eklemeniz yeterlidir.

add_shortcode( 'uye', 'member_check_shortcode' );

function member_check_shortcode( $atts, $content = null ) {
		if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
				return $content;
		return '';
}




Yazıyı Beğendiyseniz Bültenimize Abone Olabilirsiniz!


YORUM BIRAKIN