Category: Tutorials
Playing with YouTube feeds
This is a followup to my Simplepie post a while back. YouTube offers Atom feeds, great – you’d think. However the data that YouTube outputs in its Atom feeds is…a bit different to what you might expect from a standard RSS feed in that it contains a lot of escaped HTML. Essentially for each item’s descripton in the feed YouTube outputs something like the following:
<div style=”font-size: 12px; margin: 3px 0px;”><span></span></div></td>
<td style=”font-size: 11px; line-height: 1.4em; padding-left: 20px; padding-top: 1px;” width=”146″ valign=”top”><div><span style=”color: #666666; font-size: 11px;”>From:</span>
<a href=”http://www.youtube.com/profile?user=YouTube”>YouTube</a></div>
<div><span style=”color: #666666; font-size: 11px;”>Views:</span>
15774</div>
Which is basically a div that contains a table and is pretty intrusive if included in it’s native form. A rough and ready solution to just getting the bits you want (or at least I want) is to grab each … Read More »
WordPress snippet #1
Useful little piece of WordPress code, plays a particularly useful part of a dynamic featured post slideshow that I was going to detail at some point. To reference the set upload directory url in your WordPress theme:
<?php $upload_dir = wp_upload_dir(); ?>
<?php echo $upload_dir['baseurl']; ?>
more info here http://codex.wordpress.org/Function_Reference/wp_upload_dir
CSS – speeding things up
A bit of house-keeping (for wont of a better word) first, I’ll be moving this blog in the next couple of weeks to integrate with my website www.bigthingsandlittlethings.co.uk. When I first set this blog up I wasn’t entirely sure what form it was going to take but I’ve managed to keep it quite web-relevant (thus far) so it seems silly to keep two separate identities running when really they are parts of the same thing….
Now, boring stuff over, on with the blog.
This isn’t a hugely technical blog this time but covers a few CSS-related things that I have found make a big difference to workflow and just generally making things a bit easier to organise and manage.
I came across the notion of CSS ‘global resets’ a few years ago, to me they make a great deal of sense, … Read More »
WordPress – styling by category
I’ve spent the best part of this morning working out how to add a post’s category to its h2 tag’s class – which then allows me to do category-specific styling. Essentially I wanted each headline to be a different colour based on its category – simple result, slightly convoluted solution.
Anyways, it took a while so I thought I’d share it here to save others the hassle!
You first need to add the following to your functions.php file
<?php
function the_category_unlinked($separator = ‘ ‘) {
$categories = (array) get_the_category();
$thelist = ”;
foreach($categories as $category) { // concate
$thelist .= $separator . $category->category_nicename;
}
echo $thelist;
}
?>
Basically this takes the results of the usual the_category() query – i.e. an unordered list – and strips out all the list formatting and presents the results as a nice list of the categories, with each category separated by a space.
You can then add this … Read More »
Recent Comments