Created
February 18, 2017 09:20
-
-
Save bulentsakarya/961c065c84c0ef86a996c9795518c21e to your computer and use it in GitHub Desktop.
wordpress meta oluşturucu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Otomatik META Etiketleri Fonksiyonu (10/02/17 ahmethakanbesel.com.tr) | |
* | |
* Kaynak: http://ahmethakanbesel.com.tr/wordpress-eklentisiz-otomatik-seo-etiketleri-olusturma | |
*/ | |
function meta_desc_olustur() { | |
global $post; | |
if (!is_single()) { return; } | |
$meta = strip_tags($post->post_content); | |
$meta = strip_shortcodes($post->post_content); | |
$meta = str_replace(array("\n", "\r", "\t"), ' ', $meta); | |
$meta = substr($meta, 0, 125); | |
$baslik = strip_tags($post->post_title); | |
$resim = get_the_post_thumbnail_url(); | |
$link = get_post_permalink(); | |
$yazar = 'Ahmet Hakan Beşel'; // Buraya kendi adınızı veya sitenini adını yazın. | |
echo "<meta name='description' content='$meta' />"; | |
echo "<meta property='og:description' content='$meta' />"; | |
echo "<meta name='author' content='$yazar' />"; | |
echo "<meta name='twitter:card' content='summary_large_image' />"; | |
echo "<meta name='twitter:site' content='@ahmet_hakan_XXX' />"; // Twitter kullanıcı adınızı başında @ işareti ile yazın. | |
echo "<meta name='twitter:creator' content='ahmet_hakan_XXX' />"; // Twitter kullanıcı adınızı başında @ işareti olmadan yazın. | |
echo "<meta property='twitter:title' content='$baslik' />"; | |
echo "<meta name='twitter:description' content='$meta' />"; | |
echo "<meta name='twitter:image:src' content='$resim' />"; | |
echo "<meta property='og:url' content='$link' />"; | |
echo "<meta property='og:type' content='article' />"; | |
echo "<meta property='og:title' content='$baslik' />"; | |
echo "<meta property='og:image' content='$resim' />"; | |
echo "<meta property='og:description' content='$meta' />"; | |
echo "<meta property='og:site_name' content='ahmethakanbesel.com.tr' />"; // Sitenizin adını yazın | |
echo "<meta property='article:author' content='https://www.facebook.com/0ahmethakan0' />"; // Sitenin Facebook sayfa URL'ini yazın. | |
echo "<meta property='article:publisher' content='https://www.facebook.com/0ahmethakan0' />"; // Sitenin Facebook sayfa URL'ini yazın. | |
} | |
add_action('wp_head', 'meta_desc_olustur'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment