Support » Fixing WordPress » Can I put the_excerpt in my head <description> tag?

  • Hi All..

    For SEO reasons, I’d like to be able to (when viewing a single article) have the excerpt of that article in my meta ‘description’ tag of the header.

    I assume there’d have to be a <?php ?> command that’ll pull this in from the database..

    Can anyone guide me as to what this command would be??

    Thanks very much

Viewing 5 replies - 1 through 5 (of 5 total)
  • See this plugin of mine:

    Note it has two user variables now: $post_desc_length, which sets the length of the description in words; $post_use_excerpt, which tells the plugin to use the excerpt text if it exists, or force the use of the post’s content at all times.

    Perfect that works.. thanks Kafkaesqui…

    another question.. you mention i can set the amount of words etc.. how do i do that?? do you have an example line of code that’ll show me my options??

    i have limited php knowledge..

    thank you 🙂

    If you can edit the plugin files online, go to Plugins > Plugin Editor in your WordPress admin pages, and select Head Meta Description*. Right after the

    function head_meta_desc() {

    line in the plugin, you’ll see

    $post_desc_length = 20; // description length in # words

    Change the value of $post_desc_length to the number of words you want displayed in your description.

    * You can edit it offline as well, and then upload the modified version.


    why’dn’t i think of that.. 🙂

    another spanner in the works.. would it be possible to have a default description? for example on the index page, there is now no description because of the lack of a excerpt..

    any suggestions??

    A spanner? Nah…Actually, the script already outputs a description for:

    – posts and Pages => abbreviation of excerpt or content
    – category queries => category description
    – everything else => blog “tagline”

    Possibly the only things missing are the ability to override single posts/Pages with a custom field, and a different default description than the blog’s tagline. Easy peasy:

    Version 0.4 now has 4 user-configurable variables:

    Default description (if set, will override use of blog tagline).

    Length in # of words for a post/Page description.

    1 (default) = use excerpt (if exists) for description. 0 = force use of content at all times.

    Custom field key; if exists, overrides use of excerpt/content for post/Page description.

    Have fun. :)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Can I put the_excerpt in my head <description> tag?’ is closed to new replies.