• Home
  • About Mitch
  • Speaking
  • Articles
  • Contact
  • Home
  • About Mitch
  • Speaking
  • Articles
  • Contact

Digital Strategist

WordPress Developer

Content Creator

Unapologetic Punk

Mitch Canter

  • X
  • Bluesky
  • GitHub
  • Twitch
  • YouTube
  • LinkedIn
WordPress

Twitch Conditional – A WordPress Plugin for Twitch Streamers

CMDR Mitchcraft

Reading time: 2 minutes

I love Twitch. I actually spend my work day with one browser dedicated to Twitch, and subscribe to MrHappy’s daily Stream. So when rumors surfaced a few years ago their API, of course I wanted a way to interface with that API.

In doing research, I realized that a lot of streamers don’t have real websites. A few of the top ones do, but I think it’s because the automation between Twitch and a true website is “iffy” – you have to manually update every time your stream goes live, and that takes precious time away from interacting with the community (and actually streaming).

What if there was a way to automatically update your website to let people know that you were streaming – and that would turn itself off once the stream was over.

Twitch Conditional

I love the way WordPress handles conditional statements; there’s very specific “if” statements built into the core, and it lets you check for any number of flags to be set – is it a Category? is it a Tag? is it page two of some random archive? There’s a conditional for that. So what if there was a way to work with Twitch the same way?

The Twitch Conditional WordPress plugin allows you to see when you – or your favorite streamer – is online, and hides/shows content accordingly.

This plugin takes one variables in the options panel: a Client ID. You can get that from your profile: https://www.twitch.tv/settings/connections. Log in, generate a client ID, and then put it in the options pane. That’s the only set up you need.

When you’re developing your website, you can use something similar to this:

<?php if (twitch_is_live('username')) { ?>
    <p><a href="##twitch_url##">Currently Streaming Live!</a></p>
<?php } else { ?>
    <p>This Twitch user is currently offline!</p>
<?php } ?>

Breaking that down: If USERNAME is live, display a link to the twitch stream. If not, display some text that says the user is offline.

You could get really in-depth, hiding and showing entire sections of the site, embedding your twitch stream into the section so that it shows up when you go online. Or you could do a simple offline/online check with a special icon.  The possibilities are endless.

One day I’ll edit this plugin to have shortcodes – for now, the developer piece is what I was really wanted to get finished.

You can download the plugin here, on Github: https://github.com/thatmitchcanter/twitch-conditional

  • An Intro to WordPress 3.0 – Navigational Menus

    An Intro to WordPress 3.0 – Navigational Menus

    Reading time: 2 minutes

    WordPress 3.0 has plenty of new features, and all of them are worth mentioning and diving deeper into.  Over the next few days I’ll be diving into the finer features of the newest incarnation of the WordPress platform.  Everything from Custom Post Types and Taxonomies to navigational menus and all of the custom functions you…

    WordPress
  • Using Hyperlinks Correctly in WordPress

    Using Hyperlinks Correctly in WordPress

    Reading time: 2 minutes

    Any good content marketer worth his or her salt knows the value of using links in their content. It’s a good strategy to practice – whether you’re linking internally to content you’ve written in the past or to external resources you mention in posts.  However, a lot of people overlook a small, single detail that could…

    WordPress