• jasonwang1523

    (@jasonwang1523)


    Dear [Developer’s /Support Team],

    I hope this message finds you well. I am currently utilizing your Custom Simple RSS plugin for my WordPress site, which has been instrumental in enhancing my site’s RSS feed functionality. However, I’ve encountered a challenge that I hope to get your assistance with.

    My goal is to include specific custom content at the end of each RSS feed item. Specifically, I want to add a section that recommends news and includes hyperlinks to the three latest articles. Additionally, I aim to incorporate a hyperlink to the original article within each RSS feed item.

    Despite attempting to integrate this functionality by adding custom code to my theme’s functions.php file, it appears that the Custom Simple RSS plugin is filtering out my customizations. I suspect there might be a conflict or an override happening due to the plugin’s built-in functionalities.

    Could you please provide guidance or a method to achieve the following requirements without my custom code being filtered out?

    1. Append custom content, including hyperlinks to the three latest articles, at the end of each RSS feed item.
    2. Include a “Read Original Article” hyperlink within each RSS feed item, directing readers to the full article on the website.

    I encountered parameters such as csrp_meta_key, csrp_meta_value, csrp_meta_type, and csrp_meta_compare in the documentation, which seem relevant but I’m unsure how to apply them effectively for my use case.

    Any insights, code snippets, or directions on how to utilize your plugin’s filters (if available) to accommodate these customizations would be greatly appreciated.

    Thank you very much for your time and assistance. I look forward to your guidance and continuing to use your excellent plugin on my site.

    The function I specified can be displayed normally in WordPress’s preset RSS, but using the custom simple RSS plug-in will filter out my function.

    function add_custom_links_to_rss_feed($content) {
        if(is_feed()) {
            global $post; // 全域變量,用於訪問當前文章的信息
            
            // 初始化自訂內容,添加當前文章的原始連結
            $custom_content = $content;
            $custom_content .= "<p><a href='" . get_permalink($post->ID) . "'>閱讀原文</a></p>";
            $custom_content .= '<h3>看更多 記者爆料網 新聞</h3><ul>';
    
            // 獲取最新的三篇文章
            $recent_posts = wp_get_recent_posts(array(
                'numberposts' => 3, // 文章數量
                'post_status' => 'publish' // 僅已發布的文章
            ));
    
            // 遍歷這些文章,添加到自訂內容中
            foreach($recent_posts as $post) {
                $post_id = $post['ID'];
                $post_title = esc_html($post['post_title']);
                $post_url = get_permalink($post_id);
    
                $custom_content .= "<li><a href='{$post_url}'>{$post_title}</a></li>";
            }
    
            $custom_content .= '</ul>';
    
            // 返回包含原始連結和新文章列表的內容
            return $custom_content;
        } else {
            return $content;
        }
    }
    
    // 將函數掛鉤到RSS feed內容的過濾器
    add_filter('the_content_feed', 'add_custom_links_to_rss_feed');
    add_filter('call_custom_simple_rss','plugin_action_links');

    Best regards,

  • The topic ‘Assistance with Customizing RSS Feed Content Using Custom Simple RSS Plugin’ is closed to new replies.