Software Engineering in WordPress, PHP, and Backend Development

Category: Notes (Page 15 of 49)

Notes on programming-related problems that I’ve encountered while working on various projects.

Programmatically List Google Maps Markers

I’ve written a few articles on working with the Google Maps API – some simply based on the API itself, others within the context of WordPress.

Generally speaking, I’m not a huge fan of the API. Sure, it’s powerful and yes you can do a lot with the information Google makes available, but I’ve also found the initial learning curve of the API is kind of steep. Once you orient yourself with the basics, it’s not as bad to introduce new functionality, but there is something to initially getting started.

Google Maps

But I digress. That’s not what this post is all about. Instead, this post is meant to share how to solve a specific problem: Programmatically listing Google Maps markers when the map isn’t visible (say in a responsive website).

Continue reading

Importing A Large Database in MAMP

When working with WordPress databases, we’re pretty fortunate to have tools like WP Migrate DB Pro, phpMyAdmin, Sequel Pro, and so on. But there are times when importing a large database is a bit more demanding than the front-end utilities we have.

Perhaps we have to change up our PHP configuration, perhaps we’re dealing with hundreds of megabytes worth of data, perhaps we don’t have the kind of control on the environment that we need.

Whatever the case, we always have the command line. And if you’re working with WordPress, MAMP, and you’re faced with importing large databases, then you may need to stop tweaking your PHP settings and simply import the file via the command-line.

Continue reading

Quick Tip: Searching Custom Post Types

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. Continue reading

Expectations If The User Presses Enter

This post is really more of a quick tip than anything else, but if you’re in the business of building web sites or web applications in which users interact with the project and are used to using shortcuts throughout the rest of their applications, then you need to consider the case of what to do if the user presses enter.

If The User Presses Enter

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.

Continue reading

Get The Post Type of the Current Post with JavaScript

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

  • 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.
  • 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)?

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑