Kyle’s WordCamp Chicago 2014 Presentation

Here are the slides for my Shortcode Shenanigans presentation for WordCamp Chicago 2014:

Shortcode Shenanigans

I really hope everyone found my presentation useful. I had a fantastic time talking about shortcodes with everyone and had an amazing audience. Lots of great questions and excellent feedback when I finished.

Here are some tweets about the talk:

https://twitter.com/gretchendevault/statuses/477487011595448322

WordCamp Chicago 2014 was an awesome event and I had a great time. Got to meet and reunite with so many great people and learn from a host of brilliant experts in the WP community. Looking forward to many more WordCamps in the future.

https://twitter.com/natedriver/status/488766312806879232

Kyle’s WordCamp North Canton 2014 Presentations

This post is to be used as a reference for anyone who has attended my presentations at WordCamp North Canton or WordPress Ann Arbor. If you are reading this, it is likely that you attended one or both of my talks and are interested in reviewing the slides. Not too surprised as I have a terrible tendency to talk way too fast and cram too much into a presentation. Sorry.

Here are links to my two talks:

Theme Customization Best Practices

In the theme customizations talk we discussed what WordPress themes are, what child themes are, how they both work in relation to each other and then walked through several scenarios and talked about the ideal solution to each problem. In the Ann Arbor talk, we were unable to cover the final section of the presentation which dives into workflow best practices for development.

Enhancing the Admin UX for Clients

In the admin UX talk, I cover the reasons we as website creators need to very seriously consider the experience our clients have when they login to the sites we create for them. There are many consequences of bad admin UX and benefits of good admin UX and we discuss them here. Also covered are some practical examples of actions we can take to improve the admin UX.

Also, here’s a nice pic shared by Ross Johnson during the first talk at a meetup in Ann Arbor:

Talkin’ ’bout child themes

I also am very appreciative of all the wonderful people who took the time to compliment and provide feedback on the sessions. Here are some tweets from awesome people:

https://twitter.com/LittleLeafAsh/status/463019356071284736

https://twitter.com/thefierywell/status/462680310850023424

https://twitter.com/redcrew/status/462678153430044672

https://twitter.com/redcrew/status/462670641767124992

https://twitter.com/mattmcgiv/status/462586440971345922

https://twitter.com/jacki890/status/462587665305837568

https://twitter.com/mattmcgiv/status/462917508085727232

Classic Marketing Mistakes

Marketing isn’t easy. Granted. It is incredibly complicated and only increases in complexity each year. However, it has been my experience that there are many basic concepts which are commonly missed by those attempting to take a stab at marketing their business.

Warning: This post is intended to be constructive and helpful to anyone seeking to improve their overall marketing efforts however it has the potential to become a frustrated rant from someone frequently tasked with resolving issues that result from these kinds of errors.

It’s called ROI people

Marketing is my business. Its what I do. So you would expect me to always be recommending businesses increase their marketing budgets and invest in growth strategies. While I am often having this conversation, it is surprising to me how often I am telling business owners to hit the brakes.

The truth is that there are those who get that marketing is a critical element in any business plan and those who don’t. The problem that I often encounter is with those who DO embrace this reality. They develop a blind faith that any investment will work and business owners all too often find themselves throwing dollars into advertising campaigns and promotional efforts because they believe that is what they have to be doing. They recognize that any responsible business owner should be re-investing a certain percentage of their funds into growth and advertising. But what we frequently witness are marketing directors who have managed to secure an appropriate budget for their overall strategies but are completely unable to quantify their return.

This is where we usually enter the picture and inform decision makers that it is in their best interest to stop what they are doing for the time being and develop a new strategy that includes scientifically measurable goals and metrics. In this wonderful modern age of marketing, there is one type of campaign that I never have any interest in.  That is a campaign in which a return on investment cannot be conclusively measured.

Word-of-mouth marketing is not a real strategy

Nothing makes me throw up my hands like hearing that your promotional strategy incorporates “word-of-mouth advertising”. This is absolute nonsense and for the life of me I can’t understand why so many professionals actually take this seriously.

Let me be clear. Word-of-mouth (WOM)  exists. People talk . Word spreads. But there are some rules in business that must be considered before lending any credence to a WOM strategy. First, people will overwhelmingly talk more about negative experiences than positive. This means that you’d better be providing AMAZING, off-the-charts services or products, otherwise WOM will not typically be in your favor. Traditionally if a customer goes to five stores in a day and four of them provide INCREDIBLE service while one of them drops the ball, as soon as they get home the customer will be sure to post an outraged report on Facebook about the business who let them down, urging all of their acquaintances to boycott them for eternity. What do the first four businesses get? Nothing. Silence.

There’s another reason that WOM does not enter our business plans: It can’t be controlled. By definition word-of-mouth is outside the control of the marketer. It is truly more of a public relations concern than anything else. IMO the only times a serious business should be even talking about WOM would be when the PR and customer service departments are meeting. From that discussion some positive strategies may be devised with proactive measures that could incorporate the marketing department.

In most cases though, I have observed a good deal of misguided strategies where word-of-mouth is given far more credence than it warrants.

Everything changes and so must you

I’m a pretty young guy. Almost every day I’m working side by side with individuals who have been marketing businesses since before I could ride a bike. I’m not at all bothered by this and feel privileged to be able to associate with and learn from everyone in my professional network.

However, there seems to be one fact that I have come to terms with and many other’s that I have met have not. This fact is that change is a constant. What worked yesterday may not work today and what works today may not work tomorrow. We need to accept this.

When we are brought in to analyze the marketing budgets of businesses, I’m routinely surprised at how consistent the budgets tend to be year after year. This is where we always step in and ask questions like “why are you spending X dollars each year on X?” to which we often receive a reply along the lines of “because we always have”. We recognize that at some point these dollars were probably generating a reasonable return. But no matter what kind of return they were generating, this does not justify throwing exactly the same amount of money in this direction year after year. Whether we like it or not, these dollars need to be re-evaluated and re-distributed based on current data.

This is something we are talking about all the time. The mindset which we often confront consists of business owners seeking to grow their business by making a large, one time investment. Their common hope is that they can invest in say, a great website or a fresh branding initiative and they will be set for years. The newsflash for them tends to be that marketing is an ongoing investment. The smarter strategy usually is to budget recurring funds into marketing and constantly review and re-evaluate. Publish new articles. Blog. Update your site. Create new promotions. Explore new marketing channels. There are thousands of new things to do and successful businesses do them.

If it can’t be measured, it isn’t worth much

Carrying on a similar theme to the ROI notes above, the marketing that matters is the marketing you can measure. If you are ever approached with an advertising opportunity or a new promo idea one of your first questions should always be “How can I measure the results?” If it isn’t easy to quantify the return then you should look elsewhere.

We don’t always need to assume

Putting together an effective marketing strategy is complicated. When we are deciding on design elements, slogans, branding decisions, target market and so many other things, there is a lot to consider in order to make the right decision for your business. But the good news is that we don’t have to guess.

That’s right. When we want to determine what the most compelling promotion to run in a certain region would be, we can make our decisions based on more than just the pre-existing knowledge that exists in our own noggins. Loads of information and data exists that we can include in our decision making processes.

The research that is required to make truly informed decisions is something we are well accustomed to conducting. This can be a time consuming process but in the end is almost always well worth the effort. Gathering factual evidence to refute or substantiate our theories really does make a difference.

Some of the methods we may employ to gather factual evidence could be:

Ok that last one maybe not so much but the rest are just a few of the many, many resources at our disposal for educating ourselves prior to launching a campaign.

Conclusion

There are many more mistakes that could be added to this far-from-comprehensive list. Nonetheless, these are my top observations and I hope they serve as good reflection points for you as you contemplate your next move. Feel free to share any frustrations that you yourself have encountered in the comments below.

How to create WordPress shortcodes

So today we’re going to learn how to take our code snippets and turn them into handy, dandy little shortcodes.

Shortcodes are one of the coolest features of WordPress from a content creator’s perspective. They allow users to execute code segments beyond what the WYSIWYG editors can handle, keep the code consistent site wide, make things far more concise, all while editing and not having to live in fear of their code getting stripped out or boggled up when editing later. All good things.

Functions.php or plugin?

An old discussion of course. Ultimately it comes down to whether you want the shortcode to depend on the theme or not. Will you be using this shortcode on other projects? Could it be useful with a different theme? It takes almost the same amount of time whichever you choose and each will work just as well for the current project.

Let’s make a shortcode

I’m going to use a bunch of examples of actual shortcodes that I have created for recent projects.

Shortcode 1: Output string


//[op] outputs the phone number
function our_phone() {
 return "(269) 588-0556";
}
add_shortcode('op', 'our_phone');

This code will allow me and all the other authors on this site to not have to remember our phone number and also change it globally if we needed to. This was handy on a recent project where there were multiple authors on the site and multiple phone numbers. Making a shortcode like this for each one made it easier for authors put the number into their content without looking it up each time and also allowed us to change the number everywhere when we wanted to by just changing the shortcode.

Shortcode 2: Output current month


//[month] shortcode. Outputs current month.
function kjm_month() {
$kjm_date=getdate(date("U"));
return "$kjm_date[month]";
}
add_shortcode( 'month', 'kjm_month' );

This shortcode came in handy for my team because several authors were frequently writing promotional pages on the site and often the promotions were similar from month to month so this shortcode allowed them to automatically output the current month in their copy. This way they didn’t have to go back on the first of each month and update every single page that contained a monthly promotion.

Shortcode 3: Countdown timer


//[cdt] countdown timer shortcode
function content_countdown($atts, $content = null){
 extract(shortcode_atts(array(
 'month' => '',
 'day' => '',
 'year' => ''
 ), $atts));
 $remain = ceil((mktime( 0,0,0,(int)$month,(int)$day,(int)$year) - time())/86400);
 if( $remain >= 1 ){
 return $daysremain = "$remain";
 }else{
 return $content;
 }
}
add_shortcode('cdt', 'content_countdown');

Now we’re getting to a shortcode with attributes. This snippet is an only slightly modified version of one created by Kevin Chard at WPSnipp. What my version does, is it shows the number of days remaining before a specified date. This was also very handy for the authors on this site who would run monthly promotions which had an end date, and this allowed them to automatically display to the site’s visitors how many days remained before the offer would expire.  The purpose was to give a sense of urgency and drive sales.

But what’s going on inside these shortcodes

Let’s take just a second to explain some things:

  • When outputting data we always use return whereas in many normal programming instances we would use echo. Using echo will usually return some funky results.
  • The add_shortcode() function accepts two parameters. The first is the shortcode you want to create (the word(s)/phrase you enter in the square brackets) and the second is the function that it will execute.
  • Best practice for your shortcode names and attribute names would be lowercase.

There are truly thousands of things you could do with shortcodes. I greatly appreciate the ability to condense code snippets and re-use them endlessly. On a different project I took a complicated archive page on a website that had hundreds of lines of code and brought it down to four lines with massive improvements.

Here are a few ideas of what you can do with shortcodes:

  • Output strings of text
  • Make buttons
  • Create forms
  • Implement social sharing buttons
  • Embed videos
  • Embed tweets
  • Embed Facebook status updates
  • Show featured posts
  • Show featured products
  • Include custom javascript
  • Create HTML elements (tables, divs, sections, etc.)
  • Insert media
  • Insert photo galleries
  • Display countdown timers
  • Display user count
  • Display comment count
  • Insert animated sliders
  • Include interactive calculators
  • Many many many more!

I’d love to learn about what shortcodes you have created or would like to create. Share in the comments below.

How to make a basic WordPress plugin

There’s no doubt that the web is full of great tutorials on getting started with real WordPress development. Lots of developers far more talented than myself have provided helpful guides on plugin development. Even so, I am going to take the time to contribute my own tips to those wishing to take WordPress to the next level.

The basics

I think its always constructive to begin with the fundamentals. So…what are plugins?

Plugins are packages of code (can be very small to very large) that when activated within WordPress, modify or extend the features and functionality for your site.

For clarification purposes, there are (basically) four components that work together to make WordPress work:

  1. WordPress core
  2. Themes
  3. Plugins
  4. MySQL database

Whenever you want to do something cool or when you have problems these are basically the only areas of interest. It is worth noting that numbers 1 and 4 are basically never tampered with directly (unless you are super advanced or out of your mind).

Lets make a plugin

WordPress is built on PHP so that language is the basis for our plugins. If you are not familiar with PHP but have experience in other languages, this should be pretty easy for you at the basic levels. If you have no programming experience at all, this may be a little challenging but I’m confident that you can do it.

For starters, to make this as easy as possible, I created a starter plugin that should give you a great head start.

https://github.com/brashrebel/starter-plugin

All you have to do is unzip the file and begin editing files within. I recommend a program like Sublime Text but some other good options could be:

Upload that unzipped folder to the wp-content/plugins directory and you are ready to get moving.

basic wordpress plugin
The file structure for this starter plugin

Lets check out the code

For starters you’ll see that I created a couple files and a couple folders. Not every plugin requires this much stuff. In fact, many basic plugins are just a single PHP file. However, it is good practice to segment your code in a logical way so that it is easier to modify, troubleshoot and understand later.

The first file we’ll look at is the starter-plugin.php file. You’ll see that this file starts with a comment. This is an essential part of every plugin. It tells WordPress “Hey, we gotta plugin here” so it can display it as an installed plugin in your dashboard and so you can activate it.


<?php
/*
Plugin Name: Starter Plugin
Description: If you want to make a plugin, this gives you a great starting point.
Version: 1.0
Author: Kyle Maurer
Author URI: https://realbigmarketing.com/staff/kyle
*/

Below that you’ll see some more descriptive comments that are my explanations of whats going on.

The next thing you’ll see is:


require_once (dirname(__FILE__).'/admin/admin.php');
require_once (dirname(__FILE__).'/shortcodes.php');

What this does is grabs a couple of the other files included in this plugin so that they can be used as well. Just throwing files into our plugin’s directory isn’t enough, we need to include them as above.

It is worth noting that one could also use ‘include’ or ‘include_once’ instead of ‘require_once’ here. I found a great explanation of the difference between ‘require’ and ‘include’.

Next you’ll find some code for including a stylesheet. Notice that the ‘add_action’ line is commented out since I don’t actually want to enqueue this stylesheet if this plugin gets inadvertently activated.


//add_action('wp_enqueue_scripts', 'my_styles');
 function my_styles() {

 //This is for setting an optional condition for when you want to include your style (if you don't want it everywhere)
 global $post_type; //variable for getting current post type if needed
 if ($post_type == 'my-post-type' || is_singular('my-post-type')) :

//Now we actually register the stylesheet
 wp_enqueue_style("starter-plugin", plugins_url("/css/style.css", __FILE__), FALSE);
 endif;
}

The last thing in the main file is a function for including some Javascript. Just like with stylesheets, it is appropriate to enqueue your scripts properly so that they are output in the right place and at the right time.


//add_action('wp_enqueue_scripts', 'my_cool_script');

function my_cool_script() {
 wp_enqueue_script("coolscript", plugins_url("/js/script.js", __FILE__), FALSE);
}

The other files

I won’t bother to go through all the other files as they are mostly just placeholders with nothing in them but maybe a comment. I’ll mention the shortcodes one though.

I often write quick, little shortcodes for content related items I, or other authors, may use frequently. So many of my plugins have a shortcodes file. Here’s the example one from the starter plugin:


function my_shortcode() {

return "Three is the number to which thou shalt count.";
}
//This part first creates a shortcode, then names the function that gets run when we use this shortcode
add_shortcode('yippee', 'my_shortcode');

One thing worth noting, for those familiar with PHP, is that ‘return’ is used to output content in shortcodes instead of echo. You can read the codex on shortcodes for more detail.

Taking it further

Well, now you have the basics of writing a plugin. The next step is…to think of some plugins to create. There are a million-trillion possibilities (fact!) for making WordPress plugins. Here are some other suggestions and notes:

  • When adding basic functionality to your site, the option of adding your code to your theme’s functions.php file OR creating a plugin will typically be a consideration. Generally speaking, you would only use the theme option if your function is ONLY useful with the current theme AND you have little to no interest in reusing it on other sites later.
  • WPSnipp is a fantastic resource for lots of simple scripts that I think are perfect for plugin beginners. Just grab one of the many useful snippets published, modify to suit your needs and then drop it in your plugin. Boom. Done.
  • WPBeginner, DoItWithWP, WP Tuts+, CSS Tricks and DigWP are just a few of my favorite resources for cool scripts that can inspire and empower you.
  • If you manage to create a plugin that works well for you, you might consider publishing it on the WordPress Plugin Repository so that others can benefit as well. Just go here to submit one. The requirements are…not really a big deal. If it works for you and there is a chance others might also find it useful, I’d recommend just publishing it. Other users will be able to notify you of bugs and possible features to add. Its really a win-win.

I hope this was helpful to some. I’d love it if anyone shared comments with ideas on how this could be made easier as well as other tips for first time plugin developers.