I am trying to add an additional RSS feed, using a different template, to my blog. Most documentation on WordPress.org seems to be aimed at replacing an existing feed, or alter its contents.

The additional feed is meant to fulfill Peter’s request to have a comments feed that shows only real comments, not all the likes, reposts etc I also receive through WebMentions. It is a very logical request, but I also want to keep the original comments RSS feed that includes all interaction with content on this site. So I need to add a new RSS feed.

WordPress.org doesn’t really contain any complete step-by-step explanations for anything, including for adding customised RSS feeds. It also doesn’t have any info on excluding pingbacks from comment feeds, which would be similar to what I’m trying to do. I tried stuff based on snippets of documentation I did find, but couldn’t put those snippets together into a coherent path to a solution.

Then I found a guide at WPBeginner dot com (WP beginner, that’s me, even though I’ve been a WP user and tinkerer since 2004) It’s from 2016 so maybe not concurrent with today’s version of WP. Following their explanation, I added the following to my child theme’s functions.php:

add_action('init', 'extracommentsRSS');
function extracommentsRSS(){
add_feed('commentsdupe', 'extracommentsrssFunc');
}

function extracommentsrssFunc() {
get_template_part('rss2', 'commentsdupe');
}

The first part adds the new feed to WP, the second function tells it where to look for the template for the feed. That template, named rss2-commentsdupe.php, is located within the child-theme folder.

The URL for the feed now works, however it first prompted a download of an empty file due to the template file having a wrong name. With that name corrected (based on Jan’s comments below), it does load the template correctly.

The template itself still has issues (meaning it doesn’t work as intended at all): the while has_comments() loop provides no results, as it does not get passed any variables. Because the get_template_part is not provided with those variables before getting called. Jan suggested adding the query to the template. Did that, but now struggle to find a way to lift the comments from the query result.

The query below gets the latest 20 approved reactions on my site of the type ‘comment’ (as opposed to e.g. pingback or webmention):

$query = new WP_Comment_Query( array( 'status' => 'approve', 'type' => 'comment', 'number' => 20, 'orderby' => 'commentdate_date' ) );

The result if I print it as arrays, contains 7 elements (the query, the query arguments, default query arguments (?), an empty one, an array with the 20 requested WP comment objects, and two more empty ones).
The query works as intended, but now I do not know how a) to access the 5th element, and b) handle the WP comment objects within it. What seems to be intended functions for it (have_comments(), the_comment()) don’t seem to work.

The below code at least does not work. If I test it like this, it never enters the while loop, so never echoes ‘BOE’

while ( $query->have_comments() ) :
echo 'BOE';
$query->the_comment();
$comment_post = get_post( $comment->comment_post_ID );
$GLOBALS['post'] = $comment_post;
?> etc.

After some more suggestions by Jan Boddez, ao that have_comments() doesn’t work for wp_comment_query, I then established that get_comments to query the comments, and then a foreach to loop through them works the way I need it to.

$query = get_comments( array( 'status' => 'approve', 'type' => 'comment', 'number' => 20, 'orderby' => 'commentdate_date' ) );

foreach ($query as $comment):
$comment_post = get_post( $comment->comment_post_ID );
$GLOBALS['post'] = $comment_post;

Once I had that the original feed template could be fully re-used, and now validates:

[Valid RSS]

  • I use Category to Pages WUD plugin, but the author pulled that plugin.
  • I want to have a similar set-up on my local WP install, and my public one.
  • So that I can use WP pages as my personal wiki, and push parts of that into public pages on my site
  • Now trying to figure out how the current plugin works and stores categories. Jan Boddez has kindly provided some information in the comments to my blogpost on this.

Things I found out:

  • I use separate categories for my pages
  • If I deactivate the plugin those categories are no longer visible and not shown on my pages
  • If I reactivate the plugin they are back, so deleting the plugin does not delete the data (as was expected)
  • The database structure is not yet clear to me, but will find out using this image
  • Question is what is the difference in representation between a category for a post and a page
  • All links have the same structure http://blog/categories/mygreatpagecategory. However if you deactivate the plugin that goes to the front page. Reactivating the plugin brings the correct result again.
  • In my test set-up also will test what happens if I use the same categories as for postings, (or seperately named but commonly used) That might make the plugin superfluous as a whole
Posted

My current, October 2019, WP set-up is:

Theme: Sempress (with adaptations in a child theme I created)

Plugins:

  • Akismet Anti-Spam
  • Bridgy, for posting to Twitter from my site (and through the Brid.gy service getting back-feed from Twitter and Mastodon). I should be using Syndication Links as a replacement, but haven’t installed that yet.
  • Category to Pages WUD, to add categories to pages, which I use to make my 1-man ‘wiki’
  • Classic Editor, as some of the IndieWeb plugins don’t work with WordPress block structure, so I retain the old posting interface
  • IndieAuth
  • IndieWeb
  • Mastodon Autopost, to post to Mastodon from my site
  • Micropub, to allow me to post to my site using various clients such as Indigenous on my Android
  • Post Kinds, to create different types of postings, including likes, bookmarks etc.
  • Posted Today, to create ‘on this day in …’ lists of my older posts
  • Postie, to post on this site by sending an e-mail
  • Semantic-Linkbacks, to present mentions, likes etc from others in a nicer way
  • Simple Location, allows me to add locations to postings. Don’t actually use it.
  • Ultimate Category Excluder, allows me to keep specific categories on/off the front page, in/out the RSS feed, search or archive overviews. I use this a lot, creating different content streams
  • WebMention, to let other sites know I link to them, to hear from other sites they link to me
  • WebSub, not sure why I’m using it or what it does
  • Widget Context, to keep some widgets off single post pages as they interfere with correct microformats interpretation (machine readability)
  • Wordfence Security
  • Yarns, a microsub server. Not actively in use yet. I’m trying to set-up one of my existing WP test site as my microsub server. As I don’t want all my feed subscriptions in my live site’s WP database. So ideally I have the subscriptions in another site, while interacting with them from this site.

Ten of these plugins are IndieWeb related, and form a collective block of functionality.

I post in three languages on this site: English (mostly), Dutch, German (sometimes).
To better allow language detection I have added mark-up for it in various places. I also add translation links to the RSS feed items that are not in English.

Note: All my non-English posts are in specific categories that provide the language (e.g. nederlands for Dutch, and deutsch for German)

Adaptations made:

Translation links in RSS feed items

In functions.php of my (child)-theme I added (based on this code by Jan Boddez):


add_filter( 'the_content_feed', 'my_content_feed' );
function my_content_feed( $content ) {
	global $post;
$testurl = get_permalink($post);
if ( has_category( 'nederlands', $post->ID)) {
     $basetranslate = 'https://translate.google.com/translate?sl=nl&tl=en&u=';
     $testedurl = urlencode($testurl);
     $basetranslate = $basetranslate.$testedurl;
     $addedlink= '<br/><a href="'.$basetranslate.'">machine translation into English</a><br/>';
     $content = $content.$addedlink;
    }
    
if ( has_category( 'deutsch', $post->ID)) {
     $basetranslate = 'https://translate.google.com/translate?sl=de&tl=en&u=';
     $testedurl = urlencode($testurl);
     $basetranslate = $basetranslate.$testedurl;
     $addedlink= '<br/><a href="'.$basetranslate.'">machine translation into English</a><br/>';
     $content = $content.$addedlink;
    }


	return $content;
}

Setting page wide default language

The function for setting a page wide default considers two cases: when displaying a single post, and when displaying a category archive.
In functions.php of my (child)-theme I added:


function tonsempress_language_attributes($langtoets){
  // ton: if called from single or cat will have right language otherwise default
$langtoets ="en-us";
if (is_single()){
if ( in_category('nederlands') ) {
$langtoets = "nl-nl";}
if ( in_category('deutsch') ) {
$langtoets = "de-de";}
}
if (is_category('nederlands')){$langtoets = "nl-nl";}
if (is_category('deutsch')){$langtoets = "de-de";}
  // return the new language attribute
  return 'lang="'.$langtoets.'"';
}

add_filter('language_attributes', 'tonsempress_language_attributes');

Setting item language on front page

Items on the front page (!) that are in Dutch or German will get a span with their language attribute set accordingly. I changed this in index.php of the child theme, where it considers if a Dutch or German category post is being displayed, in the WordPress Loop:


<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
                    
<?php
	/* Include the Post-Format-specific template for the content.
	* If you want to overload this in a child theme then include a file
	* called content-___.php (where ___ is the Post Format name) and that will be used instead.
	*/
?>	 
<?php /* if in Dutch or German categories, on the homepage added Oct 2019*/?>
	<?php  if ( is_home() ) {
                    if ( in_category( 'nederlands' ) ) { ?><span lang="nl-nl"><?php }
                    if ( in_category( 'deutsch' ) ) { ?><span lang="de-de"><?php }
                    }
						 
                    
	get_template_part( 'content', get_post_format() );

	/* if in Dutch or German categories, on the homepage added Oct 2019*/
		if ( is_home() ) {
                     if ( in_category( 'nederlands' ) ) { ?></span><?php }
                     if ( in_category( 'deutsch' ) ) { ?></span><?php }
                    }
					 	
?>

<?php endwhile; ?>

The TechPledge is a Hippocratic oath like pledge for individual tech professionals. It is aimed at promoting human centered technology and at instilling reflective practices around tech as a key responsibility for tech professionals.

It was written during the 2019 TechFestival by the ‘Copenhagen 150’ a group of people in tech in diverse roles from over 40 countries, in 24 hours.

In the days after launch some criticisms were voiced, which are gathered below. This so it is possible to formulate a response, and perhaps adapt the TechPledge when warranted.

  • The pledge doesn’t have teeth. We need laws and regulation.
  • My specific technology(-concern) isn’t mentioned (e.g. nanotech, AI, Facebook, nuclear energy etc)
  • My specific societal concern isn’t mentioned (e.g. toxic online behaviour, verbal violence, misogyny, bigotry, hate)
  • Issues taken with specific wording (e.g. addiction, control)
  • This will not change any company’s behaviour
  • It’s too long / not concise enough (The Techpledge is 238 words, the English translation of the Hippocratic oath and the modern Geneva version are both over 300 words and the Hipprcatic oath has endured two and a half millennia
  • Will it actually be persuasive to prevent creepy (yet lucrative) behaviour?

(to be structured/added)
On addiction:
Person 1 (original tweeter:) Yes manipulation and influence exists. Yes, design shapes behavior in context. Yes, techs habits, but more like candy than heroin.

On control:
Me: It needs to be taken in the flow of the context of the techpledge.org as a whole. In that context I find it’s clearer what’s meant. For control I’d had suggested manipulation. I agree that maybe too much hinges on current perceptions of dark patterns and less timeless. That said calling out dark patterns is important. Perhaps the pledge should have said that, not willing to cooperate in designing/deploying dark patterns.
Person 2: If you are intentionally using “dark patterns”, you are intentionally using psychology to compel or addict.
Person 3: But mostly it does not make much sense. For instance fighting for democracy may in some cases entail deregulating tech or increasing control.
Me: I think you’re reading ‘control’ differently here. Control and boundaries are needed elements in any complex environment, just as allowing for emergence and experimentation, for sure. Intentionally and opaquely aiming for compulsion is a diff type of control, though.

Posted

PKM, in Harold Jarche’s terms is Personal Knowledge Mastery. I use the label loosely for the entire construct of how I collect, process and share information (see an overview of Information Strategies related blogposts), plus my personal processes for setting goals, doing my work, and reflecting on my work. This second part for instance includes the methods I use for creating ideas, evaluating them and getting to action.