通过元素添加wordpress RSS提要的动态功能



嗨,希望有人能告诉我怎么做。

这就是我所处的场景。

  1. 我有一个收集人们提交的博客url的前端提交。
  2. 然后我根据这些提交创建了一个页面,并希望用Wordpress RSS feed显示他们的博客url。

当前问题:如果您尝试将Wordpress RSS Feed小部件添加到elements页面中,您将看到它需要一个已定义的链接(静态)。在这种情况下,没有选项指向动态数据。理想情况下,这将指向表单提交的元数据或输入的自定义字段数据。

我已经尝试了多个RSS提要插件和插件,没有一个提供这种选项。有一个代码片段,使这成为可能吗?或者有一个插件可以让它发生。

有几点需要注意。

  • 我不想导入实际的帖子到我的网站。
  • 我使用elements/pro,鳄鱼块(喷气引擎)来构建我的前端提交表单。
  • 我已经创建了一个单页模板来呈现所有提交的数据。

如果上面有任何需要澄清的地方请告诉我。希望我解释得够多,能让你明白。

我正试图找出一种方法来做到这一点与他们的默认rss feed通过另一个短代码插件,可以拉该信息?或者完全支持从前端提交表单动态链接到数据字段的其他插件。

回顾一下:你填写你的网站博客网址然后如何将提交的信息解析成一个页面,该页面显示您最近的5篇博客文章作为链接或我在RSS提要的小部件/插件中定义的任何参数。

迟了两年,但也许有人仍然感兴趣。在子主题的functions-php中编写代码,替换"replace_name_of_acf_field"然后使用短代码[rss_acf]。我有ChatGPT创建的代码,它像一个魅力!^ ^

function rss_acf_shortcode($atts) {
$url = get_field('replace_name_of_acf_field');

// Check if the URL is valid
if(filter_var($url, FILTER_VALIDATE_URL)) {
// Generate the RSS feed with the URL
$rss = fetch_feed($url);

// Check if the RSS feed was generated correctly
if(!is_wp_error($rss)) {
// Get the number of entries contained in the RSS feed
$max_items = $rss->get_item_quantity(5);

// Get the RSS feed entries
$rss_items = $rss->get_items(0, $max_items);

// Create a variable to return the RSS feed
$output = '<div class="custom-rss">';

// Go through each entry of the RSS feed and add it to the output
foreach($rss_items as $item) {
$output .= '<div class="custom-rss-item">';
$output .= '<h3 class="custom-rss-title"><a href="'.$item->get_permalink().'">'.$item->get_title().'</a></h3>';
$output .= '<div class="custom-rss-content1">'.substr($item->get_content(), 0, 200).'...</div>';
$output .= '</div>';
}

// Close the RSS output
$output .= '</div>';

// Return the generated RSS output
return $output;
}
}
}
add_shortcode('rss_acf', 'rss_acf_shortcode');

最新更新