WordPress.org

Ready to get started?Download WordPress

Forums

Add an thumbail generated by timthumb in customised RSS feed (1 post)

  1. Antoine
    Member
    Posted 4 years ago #

    Hi,

    First, here is my WP configuration:
    - Theme used: Arthemia Premium
    - Extension: timthumb.php
    - Name of Owner: OVH
    - Website: http://www.mood-for.fr

    My problem.
    I try to set up a customised RSS feed with the title of each article, the first 450 characters and a thumbail. The ultimate goal is to implement this feed in MailShimp to send a "notification" e-mail to subscribers with the latest blog posts.

    I just integrated the image to illustrate each section. The idea is to use the plugin as timthumb on our homepage.

    To implement this RSS feed, I created a WordPress page with a specific template. Here is the template code:
    Code:

    1.
          <?php
       2.
          /*
       3.
          Template Name: Custom Feed newsletter daily
       4.
          */
       5.
    
       6.
    
       7.
          $numposts = 10; // number of posts in feed
       8.
          $posts = query_posts('showposts='.$numposts.'&cat=-1'); // replace the number 1 with the ID of your tumblelog category
       9.
          $more = 1;
      10.
    
      11.
          header("Content-Type: application/rss+xml; charset=UTF-8");
      12.
          echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
      13.
          ?>
      14.
    
      15.
          <rss version="2.0"
      16.
            xmlns:content="http://purl.org/rss/1.0/modules/content/"
      17.
            xmlns:wfw="http://wellformedweb.org/CommentAPI/"
      18.
            xmlns:dc="http://purl.org/dc/elements/1.1/"
      19.
            xmlns:atom="http://www.w3.org/2005/Atom"
      20.
            xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
      21.
            xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
      22.
            <?php do_action('rss2_ns'); ?>
      23.
          >
      24.
          <channel>
      25.
            <title><?php bloginfo_rss('name'); wp_title_rss(); ?> - Article Feed</title>
      26.
            <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
      27.
            <link><?php bloginfo_rss('url') ?></link>
      28.
            <description><?php bloginfo_rss("description") ?></description>
      29.
            <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
      30.
            <?php the_generator( 'rss2' ); ?>
      31.
            <language><?php echo get_option('rss_language'); ?></language>
      32.
            <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
      33.
            <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
      34.
            <?php do_action('rss2_head'); ?>
      35.
            <?php while( have_posts()) : the_post(); ?>
      36.
    
      37.
            <item>
      38.
              <title><?php the_title_rss(); ?></title>
      39.
              <link><?php the_permalink_rss(); ?></link>
      40.
              <comments><?php comments_link(); ?></comments>
      41.
              <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
      42.
              <dc:creator><?php the_author(); ?></dc:creator>
      43.
          <?php the_category_rss(); ?>
      44.
              <guid isPermaLink="false"><?php the_guid(); ?></guid>
      45.
          <?php if (get_option('rss_use_excerpt')) : ?>
      46.
    
      47.
              <description><![CDATA[<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="http://www.mood-for.fr/wp-content/themes/arthemia-premium/scripts/timthumb.php?src=<?php echo get_option('home'); ?>/<?php $values=get_post_custom_values("Image"); echo $values[0]; ?>&w=200&h=225&zc=1&q=70" alt="<?php the_title(); ?>" class="left" width="200px" height="225px"  /></a><?php the_excerpt_rss(450, $encode_html) ?>]]></description>
      48.
    
      49.
                  <?php else : ?>
      50.
    
      51.
              <description><![CDATA[<?php the_excerpt_rss(25, $encode_html) ?>]]></description>
      52.
            <?php if ( strlen( $post->post_content ) > 0 ) : ?>
      53.
    
      54.
              <content:encoded><![CDATA[<?php the_content(150) ?>]]></content:encoded>
      55.
            <?php else : ?>
      56.
    
      57.
              <content:encoded><![CDATA[<?php the_excerpt_rss(25, $encode_html) ?>]]></content:encoded>
      58.
    
      59.
            <?php endif; ?>
      60.
          <?php endif; ?>
      61.
              <slash:comments><?php echo get_comments_number(); ?></slash:comments>
      62.
          <?php rss_enclosure(); ?>
      63.
          <?php do_action('rss2_item'); ?>
      64.
    
      65.
            </item>
      66.
            <?php endwhile; ?>
      67.
    
      68.
          </channel>
      69.
          </rss>

    Now, the flow displays a picture for each article but can not find the image file: http://www.mood-for.fr/rss-newsletter-daily/. I'm not an experienced developer, so I'm lookig for help me configure the page template to display the correct thumbail for each post, using the plugin timthumb?

    Thank you in advance

Topic Closed

This topic has been closed to new replies.

About this Topic