Author Topic: PowerPress "Template Tags"  (Read 3912 times)

kvanlierop

  • Newbie
  • Posts: 2
PowerPress "Template Tags"
« on: January 01, 2012, 10:46:35 pm »
Hi Everyone.

I've started using this plugin for a podcasting network site and I'm loving it but I want to use all of the features it has to their full advantage.

What I want to do is be able to "pull out" and use in custom theme templates the information that is stored in the Category Podcast section for each specific Category Feed. What I mean is that I want to be able to pull information that is stored such as the iTunes Subscription URL settings and the Feed/Feeburner URL settings to be used in the theme templates.

Question: Is there a way to include some type of  "template tags" in theme templates to pull this information based on whatever category I happen to be on?

I know that this information is stored somewhere and want to know how to access it.

any help would be appreciated.

johnb172

  • Full Member
  • **
  • Posts: 36
Re: PowerPress "Template Tags"
« Reply #1 on: January 26, 2012, 03:18:16 pm »
Hey kvanlierop

I don't know if Powerpress has template tags designed for that. But I have been using custom functions to achieve what sounds very similar to what you are asking for. Basically I just add a custom function into my theme's functions.php that hooks into a Powerpress filter. Here's what the code looks like.

Code: [Select]
function themename_powerpress_player_links($content, $media_url, $ExtraData = array())
{
$category = get_the_category();
$curcat = $category[0]->cat_ID;

if ($curcat == 490){
   $content .= ' '.POWERPRESS_LINK_SEPARATOR .' ';
   $content .= 'Subscribe: <a href="http://itunes.apple.com/us/podcast/the-lunaticradio.com-show/id74259001">iTunes</a>';
   $content .= ' | <a href="http://fusion.google.com/add?feedurl=http://feeds.feedburner.com/lunaticradio/TxHN">RSS (audio)</a>';
   return $content;
   }
else {return $content;}
}

add_filter('powerpress_player_links', 'themename_powerpress_player_links', 100, 3);

Basically I am looking up the category ID for each post and if it matches a specific ID, it adds content to powerpress's links. Though one of the caveats with this method is that you cannot use multiple categories per post. Hopes this helps.

angelo

  • CIO, RawVoice
  • Administrator
  • Hero Member
  • *****
  • Posts: 4483
Re: PowerPress "Template Tags"
« Reply #2 on: January 27, 2012, 09:03:03 am »
Great code!

Multiple categories per post is why the Podcast Channels feature does not inner mix with WordPress categories, you can imagine the number of possibilities would be squared in that situation.

johnb172

  • Full Member
  • **
  • Posts: 36
Re: PowerPress "Template Tags"
« Reply #3 on: May 21, 2012, 01:28:52 am »
Hey everyone. I wanted to update the code I posted above with a modified version that I am not using. Because I need multiple subscribe links attached to each podcast/category, and use these same links in other areas of my site, I found it was much easier to use a blog roll. This way there is only one place that these links exist, making it much easier to update/modify over time. I had so many links that it became a hassle making sure that both functions.php and my blog roll were up to date with the latest URLs. Using the get_bookmarks() function in Wordpress, you can easily loop through each category of links. For my site I've set up a blog roll for each podcast that has RSS, iTunes, and Zune subscription links.

So now instead of typing out all of the html manually, get_bookmarks() loops through all of them.

Code: [Select]
if ($curcat == 76){
   $content .= '<br/>Subscribe: ';
   $bookmarks = get_bookmarks( array('orderby' => 'name', 'order' => 'ASC', 'category'  => 2339));
   foreach ( $bookmarks as $bm ) { $content .= sprintf( '<a class="relatedlink" href="%s">%s</a> | ', $bm->link_url, __($bm->link_name) );}
   return $content;
   }

Just make sure that when you change the arguments for get_bookmarks, you use the category for the actual blog roll category, and not the post category.
« Last Edit: May 21, 2012, 01:30:47 am by johnb172 »