Press "Enter" to skip to content

Tag: Functions

Quick Tip: WordPress “get” and “the” template functions

If you’re learning how WordPress templates work, there are two kinds of functions you’ll see a lot. What I like to call, the “get” and “the” template functions. If you haven’t noticed by now, there are functions in WordPress that seemingly do the same thing, so what is the difference? When do you use either one? Here are some examples:

“Get” function “The” function
get_the_title the_title
get_the_excerpt the_excerpt
get_the_permalink the_permalink
get_the_post_thumbnail the_post_thumbnail
get_the_date the_date
*get_the_content the_content

I learned PHP through WordPress first, before I went on to solidify my PHP knowledge outside of it. If you’re in the same boat that I was, even if you’re not a beginner in other languages like HTML and Css, here is how I learned these functions.

2 Comments

10 Pre-WCNYC Developer Tips

Are you pretty familiar with WordPress by now? Feel like you know all WordPress has to offer yet? Well after many years of WordPress development, I’m proud to say that I am still discovering new functions I’ve never used before or new capabilities behind functions I thought I knew. Since WordCamp is here in New York this weekend, clearly this is my rushed attempt to get something out there before then. Here are 10 pre-WCNYC developer tips that I hope level up your WordPress knowledge in some way. If you run into me this weekend, I’d love to hear if any of these helped you.

Leave a Comment

Escaping WordPress Template Functions. To do or not to do?

Sanitization, escaping, and validation have become a regular part of my WordPress theme development within the last year. If those words confuse you, don’t worry, I’ve got another draft in my dashboard waiting to be finished. Eventually. 😉

But for those of you that do have a general idea of what these terms mean, perhaps you’ve faced the same nagging questions I had when it came to escaping WordPress template functions. At first, I was just applying escape functions mechanically, while not truly understanding what it was that I was doing, I knew that it was a best practice. Just like WordPress hooks, over time, my understanding became less fuzzy, but until these nagging questions could be answered, I couldn’t feel confident that I was escaping correctly.

Which WordPress template functions should be escaped? Which functions already have this built into core?

By template functions, I mean functions that are regularly used throughout theme development to call content from the dashboard. Like the_title(), the_permalink(), and the_excerpt() to name a few.

This becomes harder to figure out if, like me,  you hadn’t truly dived into WordPress’ mysterious core files for browsing. Or maybe you have, but found it overwhelming to follow the rabbit hole and chain of functions while simultaneously trying to make sense of how WordPress does just one thing. It doesn’t help if your code editor doesn’t make the task any easier. I’m a huge fan of Sublime Text, but have recently been exploring PHP Storm. I won’t lie to you, I still prefer Sublime for my daily development needs, but PHP Storm has a feature that has made learning about WordPress core so much easier.

You can Shift (PC) or Command (Mac) click on any function, WordPress or not, and it will take you to the file and line where that function is written. So for WordPress core, instead of being overwhelmed by all the files in the wp-admin or wp-includes folder, PHP Storm teleports you instantly!

A power ranger teleporting.

And so, via PHP Storm, I narrowed down which core functions actually needed escaping. I threw together a reference until it’s something I commit to memory, and thought it would be useful to share said reference with a blog post. In this post, I’ll also briefly review what escaping does for us, and how we would know if a template function needs escaping. Let’s get to it!

8 Comments

5 WordPress Tools and Boilerplates to Make your Development Process Faster

If there’s one thing I learned in the web development field, it’s that time is money. There are budgets to be faithful to, deadlines to aim for, and when you’re a developer who wants nothing more than to have the most beautiful and efficient code ever – sometimes those things can come at odds.

So what do you do? Do what you humanly can. Write the cleanest most awesome code you can, but be mindful of doomsday the finish line. And try out these 5 WordPress tools and boilerplates!

Leave a Comment