Add Custom Meta Description Tags Without WordPress Plugin

tarihinde Fourlast tarafından yüklendi

In our first title, we will create a Seo-friendly url. In our second title, we will create a special description tag. We will do advanced seo work by minimizing the plugin phase.

How to Create a WordPress Seo Friendly Link

If you are new to WordPress and have not edited the permanent link settings, the link structures on your site will be installed by default as below. It pays attention to the matching title of the keyword or content in the url structures of the Google websites.

Default Link: domain.com/2020/06/03/herhangi-bir-ornek-yazi

Seo friendly link type: domain.com/herhangi-bir-ornek-yazi

Follow the steps below. WordPress login to admin panel > Settings > Permalinks

Settings > Permalink

Adding Meta Description without Using WordPress Plugin

The description tag of websites that don’t use optimization plugin displays as a summary of the last post they shared. The meta description tag is important for search engine optimization. We will optimize it with a simple code method.

Admin Panel> View> Theme Editor > functions.php

CODE:

function meta_desc_add(){
    if( is_home() || is_front_page() ){
    $meta_des = "A Special Description For Your Website.";
    echo '<meta name="description" content="' . $meta_des . '" />'; 
        }
     }
    add_action( 'wp_head', 'meta_desc_add', 4 );
    
    function meta_single_add() {
 
     global $post;
 
    if (!is_singular()) {return; }
    elseif(!empty( $post->post_excerpt)) {
    echo "<meta name='description' content='$post->post_excerpt' />";
    } 
    else 
    { $meta = apply_filters('the_content', $post->post_content);
        $meta = strip_tags($meta);
        $meta = strip_shortcodes($meta );
        $meta = str_replace(array("\n", "\r", "\t"), ' ', $meta);
        $meta = substr($meta, 0, 160);
        echo "<meta name='description' content='$meta' />";
    } 
} 
    add_action('wp_head', 'meta_single_add');

Reminder: If you do not have the knowledge and experience, please use any plugin. This arrangement may cause distortions in your theme.

Add Custom Meta Description Tags Without WordPress Plugin” İçin 5 Yorum

  1. Thank you for the auspicious writeup. It in truth was once
    a amusement account it. Glance complicated to far added agreeable from you!
    However, how can we keep in touch?

  2. When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is
    added I get four emails with the same comment.
    Is there any way you can remove people from that service?
    Cheers!

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir