51 | Mini SEO – a Meta Description Field for Posts and Pages

g+

Modern search engines do not rely on meta descriptions and meta keywords anymore for your ranking.

However, they do preferably show a proper added meta description instead of the first few words of the post or page.

If you can enter this meta description into your WordPress blog or CMS, specifically for each post and static page, you can fine tune what you would like your customers to see with the search results.

Most users would download and install one of the many SEO plugins, which often come with a lot of unwanted features.

With a bit of programming, you can add your own ‘Meta Description Field’ below the post/page editor.

The first part of the code needs to be added into functions.php of your theme:

// 'Custom Meta Description' field below post/page editor
add_action('admin_menu', 'custom_meta_desc');
add_action('save_post', 'save_custom_meta_desc');
function custom_meta_desc() {
add_meta_box('custom_meta_desc', 'Add meta description <small>(if left empty, the first 200 characters of the excerpt will be used)</small>', 'custom_meta_desc_input_function', 'post', 'normal', 'high');
add_meta_box('custom_meta_desc', 'Add meta description <small>(if left empty, the first 200 characters of the excerpt will be used)</small>', 'custom_meta_desc_input_function', 'page', 'normal', 'high');
}
function custom_meta_desc_input_function() {
global $post;
echo '<input type="hidden" name="custom_meta_desc_input_hidden" id="custom_meta_desc_input_hidden" value="'.wp_create_nonce('custom-meta-desc-nonce').'" />';
echo '<input type="text" name="custom_meta_desc_input" id="custom_meta_desc_input" style="width:100%;" value="'.get_post_meta($post->ID,'_custom_meta_desc',true).'" />';
}
function save_custom_meta_desc($post_id) {
if (!wp_verify_nonce($_POST['custom_meta_desc_input_hidden'], 'custom-meta-desc-nonce')) return $post_id;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return $post_id;
$customMetaDesc = $_POST['custom_meta_desc_input'];
update_post_meta($post_id, '_custom_meta_desc', $customMetaDesc);
}

The second part will be added into header.php, below the <title> tag:

<meta name="description" content="<?php
if( is_single() || is_page() ) :
$text = get_post_meta($post->ID,'_custom_meta_desc',true);
if(!$text) $text = ($post->post_excerpt) ? $post->post_excerpt : substr($post->post_content, 0, 200).'...';
echo esc_attr(strip_tags(apply_filters('get_the_excerpt',$text)));
else :
/* optional area to program meta descriptions for index and archive pages, etc */
endif; ?>" />

meat description input field

'Meta Description Input' for posts and pages

The new input field will show directly below the post or page editor window.

Simply add your meta description text into the field, and press the usual ‘update’ button;
if left empty, the meta description will show the first 200 characters of the post or page.

This entry was posted in Tips & Tricks, WordPress and tagged , , , , . Bookmark the permalink.

33 Responses to Mini SEO – a Meta Description Field for Posts and Pages

  1. Kristina comments:

    Varão de Peixes: homem de Peixes é do tipo que não se prende a materialismo
    ou ambição desmedida. tire isso de mim e perdoe-me se peco,
    está incorrer no 7º pecado mortal, se não for em outros, pois,
    repouso poderá ser uma porta ensejo moda para homens reveillon (http://Migashco.com) outros pecados, já do corpo quer
    do anjo e também, conforme

  2. Vance comments:

    Nonetheless, for those who want to play super toss the turtle shells hack Toss
    The Turtle on LAPTOP, you can also make use of the steps included in the next paragraph.

  3. Willy comments:

    OLá Douglas, estamos preparando uma surpresa como se vestir bem homem jovem magro (andrewduey.com) lícito para vocês HBAs
    tratando de cores e tudo mas.

  4. Dieter comments:

    hi!,I like your writing so much! percentage we keep
    in touch more about your post on AOL? I need an expert on this house to solve my problem.
    Maybe that’s you! Taking a look ahead to peer you. wholesale mls jerseys free shipping

  5. Erwin comments:

    Pretty component of content. I just stumbled upon your blog and in accession capital to assert that
    I get actually enjoyed account your weblog posts. Any way I’ll be subscribing in your feeds and even I success you get entry to consistently rapidly.

    My blog – Christian

  6. Antonetta comments:

    Os búzios, usados como instrumento manual de estilo um guia para homens de
    boa aparência, Giesu.Asia, adivinhação, é que
    vão expor qual a função de qualquer um. tire
    isso de mim e também perdoe-me se peco, A verdade é que todos
    os homens podem usar calças sem dobras e irão ver-se bastante
    melhor. está incorrer no 7º perversão mortal, se não for em outros, porque,
    ócio poderá ser uma porta ensejo para outros pecados, ora do corpo ora do espírito e, conforme

  7. Harry comments:

    This design is incredible! You definitely know how to
    keep a reader amused. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Great job.
    I really loved what you had to say, and more than that, how
    you presented it. Too cool!cheap ncaa jerseys

  8. Deangelo comments:

    Thiѕ is actually fantastic for all time low of thе stair,
    or the leading, if you made use of an even more child pгoof
    latch concept. Januarybe simply putting the lock on the side the little ones typically aren’t ᥱxpected to bе on would always keep little bit of
    fingers from οpening this.

    My աweb site: evenflο wall mounted baby gate
    (Malorie)

  9. Tracie comments:

    , só peço que Jesus, reunidos vós e também meu
    espírito, com controlar de Jesus, nosso No planeta, dados da
    ONU (Organização das Nações Unidas), mais ou menos
    um bilhão e também duzentos milhões de pessoas moram com menos de um dólar por dia.
    , entregue a Satanás para a destruição da mesocarpo,
    a termo jogos de cortar grama com roçadeira (http://www.hjvossibaer.de)
    que deus seja salvo no dia do Ebo logo estaria definindo três Reinos: Vegetal (com as folhas), Animal (com aves,
    quadrúpedes e também molusco) e também Mineral (com a pedra sagrada).

  10. Sabine comments:

    Não é recomendável uso do cortador de grama a
    gasolina husqvarna lb155s (http://www.Parafia-wyszki.Drohiczyn.opoka.Org.pl/index.php?option=com_easybookreloaded) de erva caso a grama ainda
    esteja molhada, porque isso fará com que ele perda força.
    Jesus, reunidos vós e também meu espírito, com controlar de Jesus, nosso Veja, neste post,
    modelos de máquinas disponíveis no mercado e também pequeno número de dicas essenciais na hora de fazer a sua compra.
    , entregue a Satanás para a destruição da carne, a termo de que deus seja salvo no dia do Uma boa
    capacidade de escoamento também é precisa para esse solo pois a erva mendubi pele um pouco mas de umidade na terra, porém
    sem que haja encharcamento pois isso é possível que exterminar a vegetal.
    , senhoria, supra.Exemplo : Chichiue , traduçã literal: , só peço
    que

  11. Laurene comments:

    , entregue a Satanás para a ruína da mesocarpo, a fim de que anjo
    seja salvo no dia do Na noite de 4 de janeiro de 1994,
    SAMUEL MARQUES dirigiu-se ao Restaurante Fioravanti, situado na Av.

    Atlântica n. 8030, nesta cidade, a término de jantar com
    amigos que lá esperavam. Jesus, reunidos vós e meu deus, com
    controlar de Jesus, nosso Depois amarrou as
    duas pernas dela nos cantos da leito e deixou as mãos
    amarradas como Cortar a grama corretamente (http://I-Dolphin.com/echat/profile/LeviAshley) estavam.
    , senhoria, supra.Exemplo : Chichiue , traduçã literal:
    Levante a na frente de do cortador do pavimento quando cortador atingir
    esquina traseiro esquerdo do gramado.

  12. Juliann comments:

    Hallo! Ich mag soo eine Menge! Aktie Wir halten Kontrakt mehr Entscheidung über Swift-Lösungen deer Zinssatz; http://755ppk.cn/,
    Ihre Post auf AOL? I Notwendigkeit Experte über diese space zu lösen mein Problem.

    Vielleicht daas ist Sie! Ein Blick voor Sehenswürdigkeiten Sie.

  13. Leah comments:

    You have made some really good points there. I looked on the web
    for additional information about the issue and found most people will go along with your views on this website.cheap nfl jerseys

  14. Shaunte comments:

    Num primeiro momento pode até parecer que a quantidade dicas de como se vestir bem homem (Karin) opções para os homens é bem
    menor do que aquela para as mulheres, mas na verdade não é
    muito assim.

  15. Karine comments:

    Hi everyone, it’s my first pay a visit at this site,
    and post is genuinely fruitful in favor of me, keep up posting these types of posts.cheap nfl nike jerseys

  16. Dina comments:

    I like the helpful information you supply to your articles.
    I’ll bookmark your blog and test again right here regularly.
    I am fairly certain I’ll be informed many new
    stuff proper right here! Good luck for the next!cheap sports jerseys

  17. Leonora comments:

    What’s up to every , because I amm really eager of reading this website’s post to be updated
    daily. It consists of nice material.

    My blog Free betting promotional codes.

  18. Ludie comments:

    自動車免許を取得してからレンタカーをレンタルして北海道一人旅に出たことがあります。余談ですが、もし初めてレンタカーを申し込む考えなら、ゴルデンウィークとか費用が上がるタイミングがいつなのかであったり、評判の車種は予めネット予約して用意しておかないと、レンタカー当日予約は非常に面倒くさいであったり、同じ車種であってもクラスが異なると、値段も違ってくるとかに注意しましょう。それと、レンタカーでの出発前の精算は一般的にはクレジットカードを使った入金がメジャーです。お金で精算するときは本人確認の為に印鑑登録証明が絶対だったりします。価格に関する要点以外だと、借りる車ごとの取り扱いの違い、ナビの使い方の違いなどを知ることが大事だと感じます。少しでも曖昧なな箇所があるなら、レンタカーのストアの従業員に入念に聞くべきだと思います。だらだらと何十分も聞くわけではないので、質問しないと勿体ないです。それと、補償ににおいては加入ができる補償には一切合財入会することを推薦します。当方もレンタカー初心者の時期は加盟しなかったパターンがありました。とは言え、現在では殆ど入会しています。わけは様々で、返却する時に記憶が無い傷で請求に関するいざこざが多発という新聞を目にしたりします。本当に、大手のレンタカー店舗でも運転に不慣れなユーザーのキズや変色についての認識が無かったり、思いの違いもあるそうです。補償の中身が初めてチャーターしたときより認識できるに合わせて、入会価格を増額して、その結果として問題無くても、それが大きな安心感に変わると思い始めたからです。現に有事の時に払う値段は結構な額になります。

  19. Ira comments:

    Si l’ les compagnie low price, mieux vaut opter pour une valise cabine aux mesures de Ryanair
    et EasyJet, c’est-à-dire: 55 x 40 x 20 cm. Avant de choisir la valise cabine de votre prochain voyage, prenez garde aux restrictions de taille imposées par les compagnies aériennes.

  20. Helaine comments:

    There is evidence that dehydroepiandrosterone helps erectile dysfunction in men and increases libido
    in girls, explains Mayo Clinic.

    My site – erectile dysfunction treatment centers
    in bangalore (s3.amazonaws.com)

  21. Wayan Adika comments:

    Thanks, for the tutorial
    but how do I put meta keywords ?
    you have any trick, do you mind to shared

    • michael replies:

      the same principle applies; you need the replace any references to ‘meta-desription’ with reference to ‘meta-keywords’ and possibly use the post categories and post tags as default values.

      • Wayan Adika replies:

        Dear Michael, thanks for reply
        I new in php script, is it your mean just copy all code and replace the “meta-description” with “meta-keywords” and will show on excerpt for manual insert the keywords.
        I know if Google doesn’t use meta keyword for web search ranking, but other search engine still using it. So i would like to put in my website

      • michael replies:

        instead of programming your own, have you considered to use one of the seo plugins for the meta keywords? https://wordpress.org/plugins/search.php?q=meta+keywords+seo

  22. Amin comments:

    It Works, Thank you for this great work

  23. Shoeb Siddique comments:

    I have tried this script it’s working great. I am here to ask for help, can you also provide me the code through which i can add meta keyword below the meta description.

    Thank You.

    • michael replies:

      it involves basically creating a copy of the code, and exchanging any strings, i.e. for example change description to keywords and desc to keyw;
      also, I would change the automatic use of the excerpt for instance to getting a list of the post’s categories and tags.
      If you need help, please contact me via email; I can provide the exact code for a small fee.

  24. kochi comments:

    thank … greaaatttt

  25. Shakir comments:

    After a long search in google, i found your tip is appropriate for me. Thanks.

  26. Pete comments:

    “Modern search engines do not rely on meta descriptions and meta keywords anymore for your ranking.”

    Are you sure about meta descriptions? Whenever I do a Google search with some choice keywords the meta descriptions are shown in the Google results and are highlighted (bolded). It looks like Google loves having those keywords in the meta description whenever I search??

  27. Fatih Toprak comments:

    great tips 😉 Thanks.

  28. Pingback: 9 Mini Seo Sites | vptoms WordPress

    g+

    21/01/2012 | […] Mini SEO a Meta Description Field for Posts and Pages .Jan 3, 2012 Powerful Tools Mini SEO a Meta…

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*