Let the Birds Sing (Feed WordPress Filter)

Sometimes it’s the tiny, little bitty things.

This is one of those times.1
Screen Shot 2015-03-02 at 3.48.10 PM

Issue: Lesley Bullock is an awesome ornithology instructor who has all her students doing field work and they’re aggregating their work to a main mother blog hub. She is even having them record and upload bird songs which is entirely awesome. The problem was that when aggregated, the built in WordPress player wouldn’t show up. Oddly, it’s there in the code. I could see it there taunting me (below). However, the visibility was set to hidden.

<audio class="wp-audio-shortcode" id="audio-31-1" preload="none" style="width: 100%; visibility: hidden;" controls="controls">
...blah blah blah stuff that points to things etc.</audio>

Once I realized the content was coming in, I tried the least invasive response- that is I just tried to override the CSS using the custom CSS option in Jetpack. No dice. Given that this is hardcoded into the post at the element level that wasn’t a huge surprise but it was worth a shot.2

I considered a few other options- Feed WordPress advanced filters, altering the core WordPress files . . . and they either wouldn’t do what I wanted or they felt too dramatic given the limited use case.

I eventually got to the wonderful site for Feed WordPress (far superior to the WP plugin support page). There’s all sorts of good information on creating plugins/filters for Feed WordPress. What I ended up making is incredibly trivial but it works and now Lesley and her students will have audio embeds that show up in the aggregated posts. It’s also the kind of pattern that will likely be useful in the future.3

Plugin Name: FWP+: show my shortcode audio
Plugin URI: http://feedwordpress.radgeek.com/wiki/fwp-add-source-content
Description: alters the content of incoming syndicated posts so that the hidden component is deleted
Version: 2015.04.01
Author: Tom Woodward based on radgeek.com examples
Author URI: http://bionicteaching.com
License: GPL


	/*hook=*/ 'syndicated_item_content',
	/*function=*/ 'fwp_remove_hidden',
	/*order=*/ 10,
	/*arguments=*/ 1

function fwp_remove_hidden ($content, $post) {

//removes visiblity: hidden; from the post and replaces it with nothing
	$content = str_replace('visibility: hidden;','', $content);

	// Send it back sans visibility:hidden;
	return $content;

You should also check out Max’s Zoom recorder tutorial- a little bit Portlandia, a little bit The Big Year.

1 Other times your post title is only mostly misleading.

2 Oddly enough if you add an additional audio file or even repost the original everything works as expected. I have no idea why. I couldn’t find anything that flipped any switches and eventually gave up on that track.

3 Not the jetpack kind of future, more the next week kind of future.

3 thoughts on “Let the Birds Sing (Feed WordPress Filter)

  1. Nice detective work. CSS won’t override since the style is applied directly to the content, it is more specific than the style sheet. Adding the !important in css might have worked, but the plugin is cleaner since it rewrites the post.

    Sing birds sing

    1. I had forgotten about the ! trick. I’ll have to try that.

      I also appreciate you single handedly keeping the comments here alive. I wonder how much of the Internet ecosystem we owe to the heroic efforts of Alan Levine.

Comments are closed.