tag feed plugin not displaying any posts

This worked for me previously, I believe prior to the upgrade to the latest version of WP. Please see http://web.gcc.mass.edu/wp-content/tag-feed.php?tag=featured There are multiple posts across my site with this tag, nothing is showing up. Please help! This plugin is actually the entire reason I joined WPMU DEV!

  • gccweb

    This works! I now have content at http://web.gcc.mass.edu/wp-content/tag-feed.php?tag=home-feature However, I can't get the feed to display when I try to add it to an RSS widget in a Wordpress site; you can see the error message here: http://web.gcc.mass.edu/test/alice-wonders/ Likewise when I try to display it on a straight-up HTML page with any number of Jquery RSS parsers nothing appears. Any ideas?

  • gccweb

    Yes, it's working, but it's not doing quite what I need it to do... this may be outside the scope of support, but if you have any ideas or suggestions I would appreciate it! I've customized the feed from the sites using a particular theme to include a post thumbnail in the RSS. This is working on a site-by-site basis, but the aggregate feed isn't displaying quite the same content. Compare http://web.gcc.mass.edu/news/feed/ to http://web.gcc.mass.edu/wp-content/tag-feed.php?tag=home-feature

    In tag-feed.php it's got to be this line:

    <description><![CDATA[<?php echo apply_filters('the_excerpt_rss', wp_trim_excerpt($post['post_content'])); ?>]]></description>

    In my theme functions file this is how I've added the thumb:

    function rss_thumb($content) {
    global $post;
    if ( has_post_thumbnail( $post->ID ) ){
    $content = '' . get_the_post_thumbnail( $post->ID, 'sidebar-thumb' ) . '' . $content;
    }
    return $content;
    }
    
    add_filter('the_excerpt_rss', 'rss_thumb');
    add_filter('the_content_feed', 'rss_thumb');

    How can I get this plugin to display the actual excerpt and auto-generated thumb in the <description> node and NOT simply the full post content, which is what appears to be happening now?

  • Mason

    Hmmm... I'm seeing that it's spitting out the thumbnail image in the description, followed by the larger image and full content in the RSS feed.

    To me, this would mean the correct line in tags-feed would be line 188:
    <content:encoded><![CDATA[<?php echo apply_filters('the_content_feed', $post['post_content'], 'rss2'); ?>]]></content:encoded>
    Instead of pulling the content, you'd rather pull an except without any photos, correct?

  • gccweb

    Still not what I had in mind (actually, 2.1.1 didn't produce any noticeable difference at all). The XML document reads like this

    <description>
    <![CDATA[
    <p style="text-align: center;"><img class="size-full wp-image-871 aligncenter" title="moby-dick" src="http://web.gcc.mass.edu/news/files/2011/11/moby-dick.jpg" alt="" width="308" height="308" />There are forty and odd vertebrae in all, which in the skeleton are not locked together. They mostly lie like the great knobbed blocks on a Gothic spire, forming solid courses of heavy masonry. The largest, a middle one, is in width something less than three feet, and in depth more than four. The smallest, where the spine tapers away into the tail, is only two inches in width, and looks something like a white billiard-ball. I was told that there were still smaller ones, but they had been lost by some little cannibal urchins, the priest's children, who had stolen them to play marbles with. Thus we see how that the spine of even the hugest of living things tapers off at last into simple child's play.</p>
    ]]>
    </description>
    <content:encoded>
    <![CDATA[
    <p style="text-align: center;"><img class="size-full wp-image-871 aligncenter" title="moby-dick" src="http://web.gcc.mass.edu/news/files/2011/11/moby-dick.jpg" alt="" width="308" height="308" />There are forty and odd vertebrae in all, which in the skeleton are not locked together. They mostly lie like the great knobbed blocks on a Gothic spire, forming solid courses of heavy masonry. The largest, a middle one, is in width something less than three feet, and in depth more than four. The smallest, where the spine tapers away into the tail, is only two inches in width, and looks something like a white billiard-ball. I was told that there were still smaller ones, but they had been lost by some little cannibal urchins, the priest's children, who had stolen them to play marbles with. Thus we see how that the spine of even the hugest of living things tapers off at last into simple child's play.</p>
    ]]>
    </content:encoded>

    What's in between the description and content tags is exactly the same. I want the description to look like this:

    <description>
    <![CDATA[
    <img width="80" height="80" src="http://web.gcc.mass.edu/news/files/2011/11/moby-dick-80x80.jpg" class="attachment-sidebar-thumb wp-post-image" alt="moby-dick" title="moby-dick" />There are forty and odd vertebrae in all, which in the skeleton are not locked together. They mostly lie like the great knobbed blocks on a Gothic spire, forming solid courses of heavy masonry. The largest, a middle one, is in width something less than three feet, and in depth more than four. The smallest,...
    ]]>
    </description>

    That's what it looks like in my individual site feed here http://web.gcc.mass.edu/news/feed/ which is what I'm trying to aggregate into my multi-site feed here http://web.gcc.mass.edu/wp-content/tag-feed.php?tag=home-feature

  • gccweb

    The <description> tag in this one strips out the thumbnail included in the RSS feed. It should return this:

    <![CDATA[
    <img width="80" height="80" src="http://web.gcc.mass.edu/news/files/2011/11/moby-dick-80x80.jpg" class="attachment-sidebar-thumb wp-post-image" alt="moby-dick" title="moby-dick" />There are forty and odd vertebrae in all, which in the skeleton are not locked together. They mostly lie like the great knobbed blocks on a Gothic spire, forming solid courses of heavy masonry. The largest, a middle one, is in width something less than three feet, and in depth more than four. The smallest,...
    ]]>

    instead of this

    <![CDATA[
    There are forty and odd vertebrae in all, which in the skeleton are not locked together. They mostly lie like the great knobbed blocks on a Gothic spire, forming solid courses of heavy masonry. The largest, a middle one, is in width something less than three feet, and in depth more than four. The smallest,...
    ]]>

    So close!!

  • gccweb

    Commented out the following on line 87:

    // $text = strip_tags($text);

    Now my feed is returning this for the excerpt:

    <description>
    <![CDATA[
    <p style="text-align: center;"><img class="size-full wp-image-871 aligncenter" title="moby-dick" src="http://web.gcc.mass.edu/news/files/2011/11/moby-dick.jpg" alt="" width="308" height="308" />There are forty and odd vertebrae in all, which in the skeleton are not locked together. They mostly lie like the great knobbed blocks on a Gothic spire, forming solid courses of heavy masonry. The largest, a middle one, is in width something less...
    ]]>
    </description>

    when I need it to return this with the custom size thumbnail:

    <description>
    <![CDATA[
    <img width="80" height="80" src="http://web.gcc.mass.edu/news/files/2011/11/moby-dick-80x80.jpg" class="attachment-sidebar-thumb wp-post-image" alt="moby-dick" title="moby-dick" />There are forty and odd vertebrae in all, which in the skeleton are not locked together. They mostly lie like the great knobbed blocks on a Gothic spire, forming solid courses of heavy masonry. The largest, a middle one, is in width something less than three feet, and in depth more than four. The smallest,...
    ]]>
    </description>

    Like I said, soooo close!

  • gccweb

    Unfortunately, no, that still returns the full-size image that's attached to the post. I need it to return the image thumbnail that the customized RSS feed puts out.

    NO:

    <description>
    <![CDATA[
    <img class="size-full wp-image-871 aligncenter" title="moby-dick" src="http://web.gcc.mass.edu/news/files/2011/11/moby-dick.jpg" alt="" width="308" height="308" />There are forty and odd vertebrae in all, which in the skeleton are not locked together. They mostly lie like the great knobbed blocks on a Gothic spire, forming solid courses of heavy masonry. The largest, a middle one, is in width something less than three...
    ]]>
    </description>

    YES:

    <description>
    <![CDATA[
    <img width="80" height="80" src="http://web.gcc.mass.edu/news/files/2011/11/moby-dick-80x80.jpg" class="attachment-sidebar-thumb wp-post-image" alt="moby-dick" title="moby-dick" />There are forty and odd vertebrae in all, which in the skeleton are not locked together. They mostly lie like the great knobbed blocks on a Gothic spire, forming solid courses of heavy masonry. The largest, a middle one, is in width something less than three...
    ]]>
    </description>
  • Barry

    Unfortunately, no, that still returns the full-size image that's attached to the post. I need it to return the image thumbnail

    Not sure why the width and height parts are being pulled out, but the URL of the image you have in that bit of HTML is for the full-size image, not the thumbnail. The width and height settings only change the size of the output image. You are still pulling the fullsize image out, but that's usually to do with how the image was added in the post, not the feed.. On that particular post in your system (in the edit panel) - what is the url of the image that it is using?

  • gccweb

    Should I open a new topic thread since this isn't really about the tag feed plugin not displaying any posts anymore? To repeat: now the plugin is returning identical content for both the post excerpt and the post content. When posts have a thumbnail, the excerpt returns the full-size image that's attached to the post, NOT the image thumbnail that the customized RSS feed puts out. How can I get the excerpt to return this

    <description>
    <![CDATA[
    <img width="80" height="80" src="http://web.gcc.mass.edu/news/files/2011/11/moby-dick-80x80.jpg" class="attachment-sidebar-thumb wp-post-image" alt="moby-dick" title="moby-dick" />There are forty and odd vertebrae in all, which in the skeleton are not locked together. They mostly lie like the great knobbed blocks on a Gothic spire, forming solid courses of heavy masonry. The largest, a middle one, is in width something less than three...
    ]]>
    </description>

    while the content returns this

    <content:encoded>
    <![CDATA[
    <img class="size-full wp-image-871 aligncenter" title="moby-dick" src="http://web.gcc.mass.edu/news/files/2011/11/moby-dick.jpg" alt="" width="308" height="308" />There are forty and odd vertebrae in all, which in the skeleton are not locked together. They mostly lie like the great knobbed blocks on a Gothic spire, forming solid courses of heavy masonry. The largest, a middle one, is in width something less than three...
    ]]>
    </content:encoded>

    This is all I want for Christmas!!

  • gccweb

    Not letting me attach a .zip or .txt, so here is full code cut and pasted:

    <?php
    /*
    Plugin Name: Tag Feed
    Plugin URI:
    Description: RSS2 feeds
    Version: 2.1
    Author: Andrew Billits (Incsub) / S H Mohanjith (Incsub) / Barry (Incsub)
    Author URI:
    WDP ID: 96
    */
    
    /*
    Copyright 2007-2009 Incsub (http://incsub.com)
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License (Version 2 - GPLv2) as published by
    the Free Software Foundation.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    */
    
    if (empty($wp)) {
    	require_once('../wp-load.php');
    	wp('feed=rss2');
    }
    
    /* -------------------- Update Notifications Notice -------------------- */
    if ( !function_exists( 'wdp_un_check' ) ) {
      add_action( 'admin_notices', 'wdp_un_check', 5 );
      add_action( 'network_admin_notices', 'wdp_un_check', 5 );
      function wdp_un_check() {
        if ( !class_exists( 'WPMUDEV_Update_Notifications' ) && current_user_can( 'edit_users' ) )
          echo '<div class="error fade"><p>' . __('Please install the latest version of <a href="https://premium.wpmudev.org/project/update-notifications/" title="Download Now &raquo;">our free Update Notifications plugin</a> which helps you stay up-to-date with the most stable, secure versions of WPMU DEV themes and plugins. <a href="https://premium.wpmudev.org/wpmu-dev/update-notifications-plugin-information/">More information &raquo;</a>', 'wpmudev') . '</a></p></div>';
      }
    }
    /* --------------------------------------------------------------------- */
    
    //------------------------------------------------------------------------//
    //---Config---------------------------------------------------------------//
    //------------------------------------------------------------------------//
    $tag = $_GET['tag'];
    if ( empty( $tag ) ) {
    	$tag = 'uncategorized';
    }
    
    $number = $_GET['number'];
    if ( empty( $number ) ) {
    	$number = '25';
    }
    //------------------------------------------------------------------------//
    //---Functions------------------------------------------------------------//
    //------------------------------------------------------------------------//
    $blog_public = isset($_GET['blog_public'])?$_GET['blog_public']:0;
    $tag_id = $wpdb->get_var("SELECT term_id FROM " . $wpdb->base_prefix . "site_terms WHERE slug = '" . $tag . "'");
    
    if ( empty( $tag_id ) || !is_numeric( $tag_id ) || $tag_id == 0 ) {
    	$tag_id = $wpdb->get_var("SELECT term_id FROM " . $wpdb->base_prefix . "site_terms WHERE name = '" . $tag . "'");
    }
    
    $tag_sql = " AND post_terms LIKE '%|" . $tag_id . "|%' ";
    
    $public_sql = "";
    if ( !empty($blog_public) ) {
           $public_sql = " AND blog_public = '{$blog_public}' ";
    }
    
    $query = "SELECT * FROM " . $wpdb->base_prefix . "site_posts WHERE site_id = '" . $current_site->id . "' {$tag_sql} {$public_sql} ORDER BY post_published_gmt DESC LIMIT " . $number;
    
    $posts = $wpdb->get_results( $query, ARRAY_A );
    
    if ( count( $posts ) > 0 ) {
    	$last_published_post_date_time = $wpdb->get_var("SELECT post_published_gmt FROM " . $wpdb->base_prefix . "site_posts WHERE site_id = '" . $current_site->id . "' {$tag_sql} {$public_sql} ORDER BY post_published_gmt DESC LIMIT 1");
    }
    
    function tag_feed_trim_excerpt($text) {
    	$text = strip_shortcodes( $text );
    	$text = apply_filters('the_content', $text);
    	$text = str_replace(']]>', ']]>', $text);
        // $text = strip_tags($text);
    	$text = strip_tags($text, '<img>');
    	$excerpt_length = apply_filters('excerpt_length', 55);
            $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
            $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
            if ( count($words) > $excerpt_length ) {
                    array_pop($words);
                    $text = implode(' ', $words);
                    $text = $text . $excerpt_more;
            } else {
                    $text = implode(' ', $words);
            }
    
    	return $text;
    }
    
    header('HTTP/1.0 200 OK', true);
    header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
    $more = 1;
    
    ?>
    <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
    <rss version="2.0"
    	xmlns:content="http://purl.org/rss/1.0/modules/content/"
    	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    	xmlns:dc="http://purl.org/dc/elements/1.1/"
    	xmlns:atom="http://www.w3.org/2005/Atom"
    	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    >
    
    <channel>
    	<title><![CDATA[<?php bloginfo_rss('name'); ?> <?php _e('Posts'); ?>]]></title>
    	<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
    	<link><![CDATA[<?php bloginfo_rss('url') ?>]]></link>
    	<description><![CDATA[<?php bloginfo_rss("description") ?>]]></description>
    	<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', $last_published_post_date_time, false); ?></pubDate>
    	<?php the_generator( 'rss2' ); ?>
    	<language><?php echo get_option('rss_language'); ?></language>
        <?php
    	//--------------------------------------------------------------------//
    	if ( count( $posts ) > 0 ) {
    		foreach ($posts as $post) {
    			$author_display_name = $wpdb->get_var("SELECT display_name FROM " . $wpdb->base_prefix . "users WHERE ID = '" . $post['post_author'] . "'");
    			?>
    			<item>
    				<title><?php echo apply_filters( 'the_title_rss', $post['post_title']); ?></title>
    				<link><![CDATA[<?php echo $post['post_permalink']; ?>]]></link>
    				<comments><![CDATA[<?php echo $post['post_permalink'] . '#comments'; ?>]]></comments>
    				<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', $post['post_published_gmt'], false); ?></pubDate>
    				<dc:creator><?php echo $author_display_name; ?></dc:creator>
    				<guid isPermaLink="false"><?php echo $post['post_permalink']; ?></guid>
                    <description><![CDATA[<?php echo apply_filters('the_excerpt_rss', tag_feed_trim_excerpt($post['post_content'])); ?>]]></description>
                    <content:encoded><![CDATA[<?php echo apply_filters('the_content_feed', $post['post_content'], 'rss2'); ?>]]></content:encoded>
    				<wfw:commentRss><?php echo $post['post_permalink'] . 'feed/'; ?></wfw:commentRss>
    			</item>
    			<?php
    		}
    	}
    	//--------------------------------------------------------------------//
    	?>
    </channel>
    </rss>
    <?php
    //------------------------------------------------------------------------//

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.