首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >删除或编辑提要中的<dc:creator>

删除或编辑提要中的<dc:creator>
EN

WordPress Development用户
提问于 2012-04-02 20:16:51
回答 3查看 8.7K关注 0票数 6

希望删除<dc:creator>或将其编辑为静态值,而不编辑核心Wordpress文件。最好是作为一个功能。

EN

回答 3

WordPress Development用户

回答已采纳

发布于 2012-09-11 02:03:53

  1. /wp-includes/feed-rss2.php复制到主题文件夹
  2. 编辑它,做你想做的任何更改(例如删除dc:creator的行)
  3. 在主题的functions.php文件中,添加以下函数:
代码语言:javascript
复制
remove_all_actions( 'do_feed_rss2' );  
function create_my_custom_feed() {  
    load_template( TEMPLATEPATH . '/feed-rss2.php');  
}  
add_action('do_feed_rss2', 'create_my_custom_feed', 10, 1);

Otto编辑:虽然这会起作用,但这将是一个更好的方法:

代码语言:javascript
复制
function create_my_custom_feed() {  
    load_template( TEMPLATEPATH . '/feed-rss2.php');  
}  
add_feed('rss2', 'create_my_custom_feed');

add_feed()函数是智能的,它将为您处理操作等。

注意:它需要一次性使用flush_rules()才能生效.

票数 6
EN

WordPress Development用户

发布于 2018-10-01 19:17:03

对于那些不想做PHP脚本黑客的人来说。该字段只显示文章的作者名称。如果您想要更改它的内容,请转到WP管理员,然后转到‘->’您的配置文件‘(或者转到您想要更改的特定用户那里)。然后将字段“Display”更改为要在RSS提要中显示的内容。

票数 1
EN

WordPress Development用户

发布于 2012-04-02 20:24:46

不幸的是,该元素被硬编码到WordPress核心中。看看/wp-includes/feed-rss2.php

代码语言:javascript
复制
<item>
    <title><?php the_title_rss() ?></title>
    <link><?php the_permalink_rss() ?></link>
    <comments><?php comments_link_feed(); ?></comments>
    <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
    <dc:creator><?php the_author() ?></dc:creator>
    <?php the_category_rss('rss2') ?>

    <guid isPermaLink="false"><?php the_guid(); ?></guid>
<?php if (get_option('rss_use_excerpt')) : ?>
    <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php else : ?>
    <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
    <?php if ( strlen( $post->post_content ) > 0 ) : ?>
        <content:encoded><![CDATA[<?php the_content_feed('rss2') ?>]]></content:encoded>
    <?php else : ?>
        <content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
    <?php endif; ?>
<?php endif; ?>
    <wfw:commentRss><?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?></wfw:commentRss>
    <slash:comments><?php echo get_comments_number(); ?></slash:comments>
<?php rss_enclosure(); ?>
<?php do_action('rss2_item'); ?>
</item>
票数 0
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/47726

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档