WordPress.org

Ready to get started?Download WordPress

Forums

the_excerpt_rss() and the_content_rss() not displaying in header. (2 posts)

  1. MatthewEbel
    Member
    Posted 5 years ago #

    I am seriously getting frustrated by this.

    • All I'm trying to do is dynamically change the <META NAME='description'... tag to display the excerpt for a single post and a generic site desc. for other pages.
    • This is WORKING on one of my sites, but not on another.
    • Both sites are running the same version of WP (7.1)
    • Both sites are running on the same server.
    • Both sites use the same settings for Writing, Reading, and Permalinks.
    • I have disabled all plugins, tested, and re-enabled, so don't go there.

    Here's the code that I'm using in wp-content/themes/theme/header.php for BOTH sites, starting with the first line of the file:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    
    <head profile="http://gmpg.org/xfn/11">
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    <meta name="keywords" content="Matthew Ebel Music MP3 Photos Life's Been Good Filling The Pages Beer And Coffee Goodbye Planet Earth Videos Quicktime Movies">
    
    <meta name='description' content='<?php
    if ( is_single() ) {
      the_excerpt_rss();
    } else { ?>
    This is the fan site for piano-rocker Matthew Ebel- THE place to go for exclusive access, new music, and live music from Matthew Ebel every month.
    <?php } ?>'>

    On one site it fills in the excerpt perfectly on any single-post page. For example, at http://matthewebel.com/main/2009/03/30/night-train-live-now-available-for-podcasters/ the description tag is:

    <meta name='description' content='Hear the complete concert at matthewebel.netIn case you missed the concert at FWA 2009, I have released the entire concert recording to my subscribers at Matthew Ebel dot net. That’s over an hour of one of the best live shows I’ve ever played, to one of the best crowds I’ve ever seen. If [...]'>

    But at http://matthewebel.net/2009/03/31/dance-of-the-rising-current-sample/ all I get is:

    <meta name='description' content='
    '>

    (With the line break. All I get is that freaking line break.)

    I tried screwing around with other single-post template tags to see what would happen. Usually it's the same result, but if I change the_excerpt_rss() to the_content() it gives me:

    <meta name='description' content='<br />
    '>

    What am I missing here?

  2. iridiax
    Member
    Posted 5 years ago #

    the_excerpt_rss and the_content_rss must be used within The Loop.

Topic Closed

This topic has been closed to new replies.

About this Topic