Custom RSS Feed Overwrites Permalink

I’m trying to setup a custom RSS feed for attachments with a meta field. I succeeded in making the feed, however it’s now overwriting the actual site content.

add_action( 'init', 'add_custom_feed' );
function add_custom_feed() {
  add_feed( 'photos', 'render_photos_feed');
}
function render_photos_feed() {
  //WP_Query for attachment
  get_template_part( 'rss', 'photos' );
}

I have a poor understanding of where exactly a url is created here. What I’m expecting is example.com/photos/feed or example.com/feed/photos. I’m getting example.com/feed/photos but then also example.com/photos, which is where the Page that displays my photos exists. I can flush permalinks and turn off the action for this feed and render my page, but when it’s online, I can see on the Photos page that its permalinked to photos-2. I can’t find any documentation online about why that happens.

I really don’t want to create a CPT for these, the workflow of adding a checkbox was really easy & reduces noise on the backend and the WP Query works. Secondarily, I also am wondering if it’s possible to change the main feed to be posts & photos. I can’t just hijack the feed WP_Query because its an OR logic (get posts or attachment w/ meta value). Any thoughts there are welcome too.

8 – How to rewrite a Views RSS?

The RSS Views Feeds are very restricted. I created an RSS Views Feed to display the Message (https://www.drupal.org/project/message).

I want to rewrite the RSS Views Feed and I want to display the RSS Message View mode.

I created a template for my Views :

views-view-row-rss--test.html.twig

I don’t know how to make the RSS message display mode in this template.

Here is the RSS template for Messages.

message--mas-create-node--rss.html.twig :

<item>
  <title>{{ drupal_token('message:field_node_reference:entity:title', {message: message}) }}</title>
  <link>{{ drupal_token('message:field_node_reference:entity:url', {message: message}) }}</link>
  <description>{{ drupal_token('message:field_node_reference:entity:content-type', {message: message}) }}</description>
  <pubDate>{{ drupal_token('message:created:since', {message: message}) }}</pubDate>
  <dc:creator>{{ drupal_token('message:author:display-name', {message: message}) }}</dc:creator>
  <enclosure url="{{ drupal_token('message:rss-node-render', {message: message}) }}" length="3180" type="image/jpeg"/>
  <guid isPermaLink="true">{{ drupal_token('message:url:absolute', {message: message}) }}</guid>
</item>

The RSS Feed markup in Views is very bad. It only works on node display modes and does not manage images. It does not allow tokens to be used to rewrite fields.

How to completely rewrite my Views and display the RSS display modes for my Messages ?

8 – How to create a template for an rss views?

I created an rss views in Drupal 8. I want to rewrite this views, when I enable TWIG debugging, there is no template name offered.

The machine name of my life is test is the display feed_1 I want to rewrite the views-view--row-rss.html.twig template for this views. How to do ?

https://git.drupalcode.org/project/drupal/-/blob/8.9.15/core/modules/views/templates/views-view-row-rss.html.twig

Here is the path to my view :

/admin/structure/views/view/test/edit/feed_1

enter image description here

8 – How to create a personalized RSS Feed?

I created a Views to display the Messages (from the Message module). I want to create an RSS Feed, but the RSS Feed display proposed by the Views does not manage images and does not allow the fields to be grouped together.

How to create a personalized RSS Feed ?

I created an RSS display mode for Messages and here is my template.

message.html.twig :

<item>
  <title>{{ drupal_token('message:field_node_reference:entity:title', {message: message}) }}</title>
  <link>{{ drupal_token('message:field_node_reference:entity:url', {message: message}) }}</link>
  <description>{{ drupal_token('message:field_node_reference:entity:content-type', {message: message}) }}</description>
  <pubDate>{{ drupal_token('message:created:since', {message: message}) }}</pubDate>
  <dc:creator>{{ drupal_token('message:author:display-name', {message: message}) }}</dc:creator>
  <enclosure url="{{ drupal_token('message:rss-node-render', {message: message}) }}" length="3180" type="image/jpeg"/>
  <guid isPermaLink="true">{{ drupal_token('message:url:absolute', {message: message}) }}</guid>
</item>

I want to use my view because it will have context filters. I have to rewrite it entirely.

enter image description here

rss – How do you check where the feed is being instantiated?

I need to set up a RSS feed, so the first thing I did was to check if I had a feed:

https://feedburner.google.com/fb/a/myfeeds?gsessionid=pVO3JdJC-QFJNqPlkoaNJtTYqY3Zlivw-RIJovo4Q4g

I used this and checked /feed, but it seems I don’t have any feed. How do you check to see if you have any feed available, and how do you enable or disable feed?

I received the following message: We could not find a valid feed at that address.

I also added:

add_theme_support( 'automatic-feed-links' );

inside functions.php. However, I can’t find the feed still on my local environment. Is there a way to check where the feed is instantiated?

plugins – RSS Feed on WordPress showing code (hypertext) in articles titles

The Problem:
My Rss Feed headlines have hypertext showing like <b>diving</b>

Things I have tried:
I’ve looked on forums and found plugins meant to solve it. Nothing worked. I have added code in the function file where devs have asked me to in an attempt to fix it. No dice.

How I configured the feed:
I create Google alerts. Copy each alert’s RSS link and paste it on to RSSmix.com I have also tried two other mixers, including feedburner. I then combine all the feeds in to one and then add the one rss feed to the widget.

Other Things I’ve tried:

  1. Switching themes
  2. Praying to the Spaghetti monster
  3. Turning it off and on again.
  4. Wingardium Leviosa

All have ended in fail. 🙁

The website where the problem is occuring: foodandtravel.io

Please advise.

If Samwise Gamgee can brave Mount Doom, we can sure as hell fix this RSS Feed. Together. As one.

I call upon yee my smooth brained brethren.

RSS tickler does not tick when using a collection of links rather than texts: what is wrong?

I am using a solution at: https://www.cssscript.com/rss-feed-scroller-marquee/ in order to create a tickler for my web page. All fine, but for the fact the tickler just showed the texts of the rss feed but it was impossible to click them to get to article. So I tried to tamper with it constructing a proper url and trying to animate it. Yet the item seems well constructed, but when I animate it, nothing happens. This the code of the modified js class:

/*!
* RSS Marquee
*
* Licensed under MIT
* Copyright (c) 2020 (Samuel Carreira)
*/
class RSSMarquee {
/**
*
* @param {string()} feedURLs Feed URLs
* @param {object} elementContainer the selector of the marquee container
* @param {number} options.speed duration in ms per character. Bigger values = slow speed
* @param {number} options.maxItems specify max number of titles to show (useful to debug)
* @param {object} options.hostnameSelector The selector of the element where you want to show the URL of the news feed source (usefull for copyright atttribution)
*/
constructor(feedURLs, elementContainer, options = { speed: 110, maxItems: null, hostnameSelector: null }) {
this._feedURLs = new Array();
SEMrush

if (Array.isArray(feedURLs)) {
this._feedURLs = feedURLs;
} else {
this._feedURLs(0) = feedURLs;
}

const URLvalidation = this._feedURLs.every(this.validateURL);

if (!URLvalidation) {
throw new TypeError(‘Invalid URL on list’);
}

this._urlIndex = 0;

this._anim = null;

this._newsText = ”;

this._lastTime = Date.now();

if (elementContainer === null) {
throw new TypeError(‘Invalid element selector’);
}

this._elementContainer = elementContainer;
this.styleElementContainer();

this._options = {
speed: this.validateSpeed(options.speed),
maxItems: options.maxItems,
hostnameSelector: options.hostnameSelector,
// …options
};

this.getRSS();
}

validateSpeed(speed) {
if (!Number(speed) || speed < 50 || speed > 300) {
return 110; // default safe value
} else {
return speed;
}
}

/**
* Set the animation speed
* @param {number} speed value between 50-300
*/
set setSpeed(speed) {
this._options.speed = this.validateSpeed(speed);
}

get getSpeed() {
return this._options.speed;
}

/**
* Validate URL (uses URL interface)
*
* @param {string} url Url to check
* @returns {boolean} true if valid
*/
validateURL(url) {
try {
const u = new URL(url);
return true;
} catch (e) {
return false;
}
}

/**
* Get Hostname from url string
*
* Sample: “https://www.dnoticias.pt/rss/desporto.xml”
* returns url
*
* @param {string} url url string
* @returns {string} hostname
*/
getHostname(url) {
try {
const u = new URL(url);
return u.hostname;
} catch (e) {
return ”;
}
}

getRSS() {
const url = this._feedURLs(this._urlIndex);

this.fetchRSS(url)
.then((xmlText) => {
this._newsText = this.parseXMLFeed(xmlText);

this.showMarquee(this._newsText);

this.showHostname(url);
})
.catch((err) => {
console.error(err);

this.handleErrors();
});

}

handleErrors() {
const diffTime = Date.now() – this._lastTime;

if (diffTime > 5000) {
console.log(‘Trying next feed URL…’);

this.nextURL();
this._lastTime = Date.now();
} else {
if (this._newsText === ”) {
console.log(‘delay…’);
setTimeout(() => {
this.nextURL();
}, 5000);
} else {
console.log(‘show again cached saved news’);
this.showMarquee(this._newsText);
}
}
}

nextURL() {
this.increaseIndex();

this.getRSS();
}

styleElementContainer() {
this._elementContainer.style.overflow = ‘hidden’;
this._elementContainer.style.whiteSpace = ‘nowrap’;
}

showHostname(url) {
if (!this._options.hostnameSelector) {
return;
}

this._options.hostnameSelector.innerText = this.getHostname(url);
}

showMarquee(aCollection) {

try {
const animKeyframes = ({
transform: ‘translateX(0)’
},
{
transform: ‘translateX(-100%)’
}
);

const animOptions = {
duration: 25000, // The number of milliseconds each iteration of the animation takes to complete. Defaults to 0. Although this is technically optional, keep in mind that your animation will not run if this value is 0.
easing: ‘linear’, // The rate of the animation’s change over time. Accepts the pre-defined values “linear”, “ease”, “ease-in”, “ease-out”, and “ease-in-out”, or a custom “cubic-bezier” value like “cubic-bezier(0.42, 0, 0.58, 1)”. Defaults to “linear”.
iterations: 1, // The number of times the animation should repeat. Defaults to 1, and can also take a value of Infinity to make it repeat for as long as the element exists.
delay: 0, // The number of milliseconds to delay the start of the animation. Defaults to 0.
endDelay: 0 // The number of milliseconds to delay after the end of an animation. This is primarily of use when sequencing animations based on the end time of another animation. Defaults to 0.
};

animOptions.duration = aCollection.length * this._options.speed;

const elementChildNode = document.createElement(‘span’);
elementChildNode.style.display = ‘inline-block’;
elementChildNode.style.paddingLeft = ‘100%’;

//const textNode = document.createTextNode(text);
console.log(aCollection.lenght);
aCollection.forEach(function(item, index, array) {
elementChildNode.appendChild(item)
})
console.log(“totale:”);
console.log(elementChildNode);
//elementChildNode.appendChild(textNode);

//this._elementContainer.appendChild(elementChildNode);

this._anim = elementChildNode.animate(animKeyframes, animOptions);
console.log(‘start animation’);
this._anim.onfinish = () => {
console.log(‘end’);
while (this._elementContainer.firstChild) {
this._elementContainer.firstChild.remove();
}
delete this._anim.onfinish;

this.nextURL();
};

this._lastTime = Date.now();
} catch (err) {
console.error(err);
}
}

increaseIndex() {
this._urlIndex += 1;
if (this._urlIndex > this._feedURLs.length – 1) {
this._urlIndex = 0;
}
}

/**
* Fetch RSS
* @param {string} feedURL RSS XML url
*/
fetchRSS(feedURL) {
return new Promise((resolve, reject) => {
console.info(`Start fetching ${feedURL}…`);

fetch(feedURL, { mode: ‘cors’, redirect: ‘follow’ })
.then((response) => {
return response.text();
})
.then((xmlTxt) => {
return resolve(xmlTxt);
})
.catch(() => {
console.error(‘Error in fetching the RSS feed’);
reject();
})
});
}

/**
* Parses RSS XML feed
*
* – Select title elementContainer
* – add dot separator between “headlines”
* – remove <!(CDATA( string
* – remove html tags
*
* @param {string} xmlText
* @returns {string} parsed feed
*/
parseXMLFeed(xmlText) {
try {
const parser = new DOMParser();
const doc = parser.parseFromString(xmlText, “text/xml”);

let news = ”;
let aCollection=();
let totals = 0;

for (let item of doc.querySelectorAll(‘item’)) {
let title = item.getElementsByTagName(“title”)(0).childNodes(0).nodeValue;
// let description = item.getElementsByTagName(“description”)(0).childNodes(0).nodeValue;
let link = item.getElementsByTagName(“link”)(0).childNodes(0).nodeValue;
if (title) {
if (news.length) {
news += ‘xa0’ + ‘ • ‘ + ‘xa0’;
}
title = this.remoteCData(title);
title = this.stripTags(title);
news += title;
var a = document.createElement(‘a’);
var linkText = document.createTextNode(title);
a.appendChild(linkText);
a.title = title;
a.href = link;
aCollection.push(a);
totals += 1;
}

if (this._options.maxItems !== null && totals >= this._options.maxItems) {
console.info(‘Maximum items reached!’);
break;
}
}
//console.log(aCollection);
//console.log(news);
console.info(`Parsed ${totals} title(s)`);
return aCollection;
} catch (err) {
console.error(err);
return ‘ ‘;
}
}

stripTags(textWithTags) {
return textWithTags.replace(/<(.|n)*?>/g, ”);
}

remoteCData(originalText) {
return originalText.replace(“<!(CDATA(“, “”).replace(“))>”, “”);
}
}

The non occurring animation is in function: showMarquee(aCollection). The original site shows how to test it.

Thanks,

 

php – How to extract RSS Data with g prefix

I have the following RSS I am not able to get the item tiles with g prefix <g:title>Co with the flow</g:title> but if I just use <title>Co with the flow</title> it’s working fine. Can anyone guide me what I am missing

<channel>
<title>De Meerse</title>
<link>https://www.demeerse.nl</link>
<description>Events</description>
<item>
<g:id>61004</g:id>
<g:title>Co with the flow</g:title>
<g:description/>
<g:link>https://www.demeerse.nl/agenda/co-with-the-flow-4/</g:link>
<g:image_link>https://www.demeerse.nl/content/uploads/2021/02/Co_with_the_flow_liggend_metlogo-scaled.jpg</g:image_link>
<g:availability>out of stock</g:availability>
<g:availability_date>202201121033</g:availability_date>
<g:expiration_date/>
<g:price/>
<item>
<g:id>3846</g:id>
<g:title>BNNVARA Leids Cabaret Festival</g:title>
<g:description/>
<g:link>https://www.demeerse.nl/agenda/bnnvara-leids-cabaret-festival-2/</g:link>
<g:image_link>https://www.demeerse.nl/content/uploads/2019/08/img18324_orig.jpg</g:image_link>
<g:availability>out of stock</g:availability>
<g:availability_date>201905250700</g:availability_date>
<g:expiration_date>202106202030</g:expiration_date>
<g:price>19.7500</g:price>
<g:custom_label_0>
<!(CDATA( Finalistentour ))>
</g:custom_label_0>
<g:custom_label_1>202106202030</g:custom_label_1>
<g:custom_label_2>202106202305</g:custom_label_2>
<g:custom_label_3>Cabaret en kleinkunst</g:custom_label_3>
</item>
</channel>
</rss>

<?php

$uri = 'https://www.demeerse.nl/agenda/?feed=adwords_xml_events';
$feed = fetch_feed($uri);
foreach ($feed->get_items() as $item){

?>
    <div class="feed-item column-one">
        <h1><?php echo html_entity_decode($item->get_title()); ?></h1>
    </div>
<?php }  ?>

feed – Debugging problems with WordPress RSS widget?

I’m trying to add an RSS feed to a wordpress site using the RSS widget. When I enter the URL into the RSS widget I get RSS Error: WP HTTP Error: A valid URL was not provided. (or sometimes I get nothing — no error, but no content).

The feed validates successfully using the W3C feed validator.

If I expose the feed on a different site (e.g., grab the feed content with curl, serve it somewhere using a simple http server, and point the rss widget at it), it works just fine.

This leaves me to wonder if the RSS widget is experiencing some failure unrelated to the feed itself…stale DNS? Something else?…but I’m not sure how to diagnose that. This is a hosted wordpress site so the only access I have is via the WP UI. Is there anything I can do to figure out why exactly the RSS widget is failing?


To be clear, this works just fine:

  • curl -o feed.xml https://.../feed.xml
  • darkhttpd . --port 8080
  • ngrok http 8080

…and then point the RSS widget at the ngrok url.

So the same content, fetched from the canonical location, just hosted at a different URL.

[cXF] RSS Feeds for Single Nodes | NulledTeam UnderGround

Description:
Add RSS icon on forum list for every single node, on forum view next to forum title and customize them.

*works great with our [cXF] Grid Nodes add-on

Features:

  • Show RSS icon on forum list
  • Show RSS icon only on node hover
  • Show RSS icon next to Node title
  • Show RSS icon on top position
  • Show RSS icon next to board title
  • Show RSS icon on forum view
  • Hide RSS icon on…

.