WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] RSS 2.0 excerpt / full RSS query / post excerpts glitch (12 posts)

  1. altfg1
    Member
    Posted 3 years ago #

    Hello,

    I'm going to try to make this as simple as possible:

    I need RSS 2.0 feeds to be full feeds (it's imperative, as we're IMDb newsdesk partners)
    but
    I need tag/archive pages to show **only** post excerpts. Else, they'll be considered dupes by the search engines.

    On WordPress' Reading page, I have "full text" checked for the RSS feed.

    However, when I tried using the following functions.php command to reduce the number of words found in tag/archive pages, it also affected the RSS feed:

    if (function_exists('add_filter'))
    add_filter('excerpt_length', 'my_excerpt_length');
    function my_excerpt_length($length) {
    return 900; // Or whatever you want the length to be.
    }

    Right now it's returning 900 words because that's pretty much the max. length of our posts. I wanted to set it to 55 or 60. But that would limit to 55-60 the number of words on a feed -- even though, as I explain above, I have "full RSS text" selected on WordPress' Reading page.

    That has been frustrating, as I've needed to use our robots.txt file to block search engine access to the site's tag pages -- when I'd like those to be searchable.

    So, the question is: how can I limit the number of words in the WordPress tag/archive pages, while keeping a full RSS feed??

    Any assistance would be much appreciated.

  2. I need tag/archive pages to show **only** post excerpts. Else, they'll be considered dupes by the search engines.

    They won't really impact SEO, but the easiest way would be to edit your theme and make a template page for archives that only shows the_excerpt.

    http://codex.wordpress.org/Template_Hierarchy

  3. altfg1
    Member
    Posted 3 years ago #

    Ipstenu,

    Thank you for your response.

    I was wondering if there's a way to modify the functions.php command to have it filter ONLY excerpts -- NOT RSS feeds.

    Thanks again.

  4. Probably, but it's easier to just edit the archive.php file for your theme, isn't it? I mean, the function would run EVERY time anyone hit ANY page. Archives would just hit up archives (and tags and categories).

  5. altfg1
    Member
    Posted 3 years ago #

    Ipstenu,

    Thanks again. Much appreciated.

    Now, I'm quite ignorant when it comes to .php coding. I think I understand what you're saying, but I'm wondering:

    a) there's an archives.php template. If I change that, will that make the blog's page 2, 3, 4, etc. show *only* the excerpt? (That would be great!)

    b) what coding would I have to change to ensure that only the excerpt would be shown on the archive/tag pages (please see php code below)? (I've checked out the link found in your previous reply, but there was nothing there about excerpts.)

    c) While I'm at it ... is there a way to have the homepage show only excerpts -- without the need for a plugin?

    Below is the "main" php code for the tag page:
    (and thanks again)

    <h1 class="page-title archive-title">Tag Archives: <span id="tag-title"><?php single_tag_title(); ?></span></h1>
    				<?php while ( have_posts() ) : the_post(); ?>
    
    				<!--BEGIN .hentry-->
    				<div id="post-<?php the_ID(); ?>" class="<?php semantic_entries(); ?>">
    					<h2 class="entry-title"><a>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    
    					<!--BEGIN .entry-meta .entry-header-->
    					<div class="entry-meta entry-header">
    						<span class="author vcard">Written by <?php printf( '<a>ID, $authordata->user_nicename ) . '" title="' . sprintf( 'View all posts by %s', $authordata->display_name ) . '">' . get_the_author() . '</a>' ) ?></span>
    						<span class="published">on <abbr class="published-time" title="<?php the_time( get_option('date_format') .' - '. get_option('time_format') ); ?>"><?php the_time( get_option('date_format') ); ?></abbr></span>
    						<span class="meta-sep">—</span>
    						<span class="comment-count"><a>"><?php comments_number( 'Leave a Comment', '1 Comment', '% Comments' ); ?></a></span>
    						<?php edit_post_link( 'edit', '<span class="edit-post">[', ']</span>' ); ?>
    					<!--END .entry-meta .entry-header-->
                        </div>
  6. altfg1
    Member
    Posted 3 years ago #

    I think I've found a solution for the tag/archive excerpts. Will confirm this once I check out site's latest post on the IMDb. That'll probably take another half hour until they update their feed.

  7. a) Yes exactly :) That's precisely how it works.

    Template hierarchy in themes is really useful: http://codex.wordpress.org/Template_Hierarchy

    b) and c)

    Look in the index.php and archive.php file for a line with the_content()

    Change it to the_excerpt()

    Note: There is a DIFFERENCE between archives.php and archive.php - One handles the archive POSTS and one the LIST of posts :) The link I gave you for template hierarchy is key here to remember which is which.

  8. altfg1
    Member
    Posted 3 years ago #

    Once again, Ipstenu, thank you.

    I did the "excerpt" change.

    Many thanks!

  9. altfg1
    Member
    Posted 3 years ago #

    Uh-oh...

    Once I removed the "excerpt" code from the functions.php template (see below), the RSS feed has stopped going out in full. It's now only a 55-word excerpt as well...

    How can I resolve this problem?

    The RSS feed *is* set for "full text." Why the summary?
    http://www.altfg.com/blog/feed/ (IMDb gets only the feed's description, which is 55 words or so...not enough for the IMDb to accept the submission)

    Any changes I can make to this functions.php code so I can reinsert it -- to set # of words for archive excerpts while allowing the RSS feed to keep sending out the full text?

    if (function_exists('add_filter'))
    add_filter('excerpt_length', 'my_excerpt_length');
    function my_excerpt_length($length) {
    return 900; // Or whatever you want the length to be.
    }

  10. altfg1
    Member
    Posted 3 years ago #

    I'm having trouble believing this myself, but I've actually managed to get the code working (via functions.php). Note: it had to be done in this particular order. Else, it didn't work.

    if (function_exists('add_filter'))
    add_filter('excerpt_length', 'my_excerpt_length');
    function my_excerpt_length($length) {
    if( is_home() ) {
    $length = 70;
    } else {
    $length = 900;
    }
    return $length;
    }

    if (function_exists('add_filter'))
    add_filter('excerpt_length', 'new_excerpt_length');
    function new_excerpt_length($length) {
    if( is_archive() ) {
    $length = 55;
    }
    return $length;
    }

  11. Sorry, I jumped up to Montreal for the weekend :)

    It LOOKS like your theme doesn't let per-templates handle that sort of thing, and instead put it all in the functions, which is certainly an option.

  12. altfg1
    Member
    Posted 3 years ago #

    It worked. And once again, thanks for the tips.

Topic Closed

This topic has been closed to new replies.

About this Topic