Category / Notes

Say what you will about the built in WordPress search functionality – sure, it could stand to be improved (personally I’m a fan of SearchWP) – but not all projects warrant the same requirements, right?

Sometimes, the built-in search functionality works just fine out-of-the-box. It gets a little more involved if you start introducing, say, custom taxonomies or custom post types, though.

That is, say you’re working on a project or have a client who needs help with modifying the built in search functionality so that it allows for searching custom post types. There’s actually a lot of flexibility provided in how you tailor the search results, but for this case it’s pretty easy.

That is, if the end user is using the project you’re working on in order to, say, submit information to the server via a form, then they shouldn’t necessarily have to manually use the mouse (or trackpad) to click on the ‘Submit’ button in order for their information to be transmitted across the wire.

If you’re an experienced web developer, then you’re likely familiar with using JavaScript to handle situations like this, but if you’re new to the business or just new to working with JavaScript then here’s the basics for handling this use case.

Whenever you need to get the post type for a given post, there are a couple of ways to do this:

1. If you’re in the dashboard, then you can use `get_current_screen()` and then access the `id` property of the object that’s returned. You can read more about this in the Codex.

2. If you’re on the front-end (or even in the dashboard, really), you can use `get_post_type`. This is also covered in the Codex.

But what if you want to grab the post type of the post that’s currently being edited on the client-side (read: via JavaScript)?

Out-of-the-box, the meta boxes that WordPress displays on the dashboard aren’t exactly overkill. I mean, if you’re a blogger, then I think the chances are strong that you’ll need: Publish Categories Tags Comments And maybe the Excerpt feature (depending on your theme) But if you’re building a solution for someone else where that information is irrelevant, wouldn’t […]

Throughout this series, I’ve been talking through the process of how go about adding a TinyMCE button to WordPress – specifically, adding a custom button to the post editor.

Up to this point, I’ve covered a number of different things. Namely:

– Stubbing out the plugin and adding the JavaScript
– Including any dependent files that you may need in order to power your plugin
– And how to bootstrap the plugin so that it is able to be activated from within WordPress

The thing is, we haven’t actually made anything happen in the editor let alone even introduce a button into the actual editor yet. In this post, we’ll do exactly that.

Remember that when adding a button to the post editor in WordPress, a portion of the code is going to be writing a plugin for the TinyMCE editor (since that’s what the actual post editor is).

In a sense, you’re placing a plugin within a plugin. That is, you’re placing a TinyMCE plugin within a WordPress plugin.

Anyway, in an attempt to modularize the code, you’ll likely have at least a couple of files that power the plugin – one of which that will be specifically for the TinyMCE button and one of which that will be specifically for other logic that fires when the button is clicked (like displaying a modal or something like that).

If you’re interested in adding a TinyMCE button to WordPress, then this series of articles aims to do just that. In the first post of the series, I walked through some of the basic things that need to be done in order to get started with adding a custom button.

I laid out the file organization, the basic plugin structure, some of the foundational JavaScript, and started working on the hooks that are necessary for adding a custom button.

As it stands right now, the functions responsible for adding a new button aren’t actually defined within the context of a class much less hooked into the plugin itself. So in this post, we’ll take a look at exactly how to do exactly that.

Starting with this post, I’ll walk through the process for how we can go about adding a TinyMCE button to WordPress in projects for ourselves or clients.

Yesterday, when I was sharing some thoughts on the nature of WordPress Menus and The Customizer I ended up on a tangential series of thoughts on my opinion and perspective on the nature of the social Internet. Then I cut it if for no other reason that it was off topic. Anyway, the original content included my thoughts on […]

/ June 14, 2015 / Comments Off on A One Week Break From Twitter

A One Week Break From Twitter

I rarely, if ever, make any kind of posts like this because they’ve always struck me as somewhat meta and I think that they can sometimes represent oneself as if they are more important than they really are. So here’s a big shot of my profile to disprove that :). But seriously, maybe that’s what will happen from […]

Starting with WordPress?
WPBeginner
I recommend Array Themes
Array Themes
Hosted By
Hosted By SiteGround