2012-07-24 96 views
1

我试图设置用户会看到的RSS提要的样式。因此,他们只能看到帖子中的图像,所见即所得编辑器中的文字以及作为主题一部分的按钮。样式化RSS提要?

这里是从的single.php模板文件中的按钮:

<div class="bottomgift clearfix"> 
<a target="_blank" rel="nofollow" href="<?php getCustomField('Affiliate Link'); ?>" class="go-button">Go</a> 
</div> 

如何添加这一切样式的RSS源?

在functions.php的

function modRSS($content) { 
    global $post; 

    if (has_post_thumbnail($post->ID)){ 
     $content = '<div>' . get_the_post_thumbnail($post->ID, 'full', array('style' => 'margin-bottom: 15px;')) . '</div>' . $content; 
    } 

    $content = $content . '<a href="' . getCustomField('Affiliate Link') . '">Go</a>'; 

    return $content; 
} 

add_filter('the_excerpt_rss', 'modRSS'); 
add_filter('the_content_feed', 'modRSS'); 

回答

1

您可以在前面或修订任何语法WordPress的RSS很容易饲料。

这里有一些代码要做,从这里拿... http://webdesignzo.com/show-featured-images-in-rss-feed-feedburner/修改了一点为你的目的。

function modRSS($content) { 
    global $post; 

    if (has_post_thumbnail($post->ID)){ 
     $content = '<div>' . get_the_post_thumbnail($post->ID, 'thumbnail', array('style' => 'margin-bottom: 15px;')) . '</div>' . $content; 
    } 

    $content = $content . '<div class="bottomgift clearfix"><a target="_blank" rel="nofollow" href="' . getCustomField('Affiliate Link') . '" class="go-button">Go</a</div>'; 

    //Adding Custom Fields 
    $content = $content . get_post_meta($post->ID,'custom_field_name', true); 

    return $content; 
} 

add_filter('the_excerpt_rss', 'modRSS'); 
add_filter('the_content_feed', 'modRSS'); 

我的代码是未经测试这样的事情应该是你在找什么。

P.S.这不是造型每个说作为您的问题标题建议,但更多添加标记。

+0

今天我会试试这个,当我回到我的电脑,让你知道它是怎么回事!谢谢! – 2012-07-24 15:20:26

+0

很酷,让我们知道。 – Foxinni 2012-07-25 11:31:09

+0

等待客户对RSS设置的响应,但是当我将你的代码粘贴到functions.php中时,我在55行的functions.php中发现错误,这是我粘贴代码的地方。我测试了一个来自你链接的网站,这样做确实有效,但问题是当我发布新帖子时,RSS并没有更新,所以我无法测试它,看看它是否还能正常工作,这就是为什么一直存在延迟。今天应该得到答复,然后我会让你知道它如何去感谢! – 2012-07-30 17:48:05