Software, Engineering, Development, and WordPress

Category: Articles (Page 2 of 247)

Personal opinions and how-to’s that I’ve written both here and as contributions to other blogs.

Working with Multiple User Metadata Queries

In one of the most recent issues of The Repository (which is a worth a subscribe), I said that one of the Twitter account I recommend following is @mattmedeiros. And though he and I never see eye to eye on anything 😏, I said:

I really like what [Matt’s] doing with The WP Minute. I think his commentary, perspective on business and the WordPress economy, and the type of journalism he’s doing is different from many others.

And I meant it.

As he’s working to grow the type of news that he’s covering, he’s also getting back to something that I think that’s either been missing, fragmented, or missing because it’s fragmented too much across the various ways we’re sharing information: WordPress tutorials.

Continue reading

A Backend Engineer Learns to Build Block Editor Blocks, Part 4

At this point, we’re half way through a major improvement to the block we’ve been working on. We have the ability to edit the content in the editor but we aren’t able to save it and because we aren’t able to save it, we aren’t able to view it on the frontend.

Now, though, we’re at a place where we can save our data, render it on the frontend, and continue to make sure that what the author sees is what the visitors see.

As I’ve done with the rest of the series, I recommend reading these first parts because they are going to bring you up to speed on everything you need to do to get up to this point:

  1. Required Tools, Plugin Structure, Dependencies, Block Metadata
  2. The Backend, The Frontend, Functionality, Styles, a Working Demo
  3. Block Attributes, Editable Content, Components, Editor Styles

Note that I still don’t have a GitHub repository set up for this plugin. I will once we reach a certain point, but not yet. And that’s because I think reading through the material and having to implement it versus cloning and changing a few things around can help you learn some of this material faster.

Anyway, I ended the previous post stating:

We’re going to cover

  • how to save the content,
  • render it on the frontend

And that will wrap up this initial part.

So that’s what we’re going to do.

Continue reading

A Backend Engineer Learns to Build Block Editor Blocks, Part 3

The first two articles in this series have been long. Not only long in terms of the content they cover, but long in comparison to the usual content I write. Part of this is because of the nature of what I’m trying to cover and part of it has to do with getting the basic plugin going.

We’re at a point now, though, where we can start to shorten the length of the article and focus more narrowly on the functionality and its implementation.

If you’re stumbling across this series and this is the first post you’re reading or you’ve not done any of the work prior to get everything off the ground yet (as I don’t have a GitHub repository set up for this plugin just yet – and that’s on purpose 🙂), here’s what’s been covered so far:

  1. Required Tools, Plugin Structure, Dependencies, Block Metadata
  2. The Backend, The Frontend, Functionality, Styles, a Working Demo

In the previous article, I stated:

In the next article, we’ll start talking about how we can edit text within the context of the Block Editor, how to save the changes, and then view them on the frontend.

Originally, I planned to cover the following in a single article:

  • convert the element in the block editor into a field we can edit,
  • save the content of the field,
  • render the content that’s above

Instead, I’m going to cover just the first point above so we can focuses solely on the editor and how to manipulate data within its context. Then we’ll follow the article up with how to save the content and render it on the frontend.

Continue reading

Quick Tip: Show All Users Sorted by Metadata

In the previous post on sorting users by meta data, I concluded with the following:

Note that how the status is set will depend on the plugin you’re working on and whether or not you want to render a column on the All Users page for this. And I can show that in another tip in a future post.

By this, I mean that it’s one thing to actually sort the users on the All Users page but it doesn’t make a lot of sense unless there’s a column by which the status is shown and the value of said status.

Given that, here’s how we can show all users sorted by the metadata that we reviewed in the previous post.

Continue reading

Quick Tip: Sort All Users by Metadata

If you’re working with the All Users screen in WordPress and want to sort all users by metadata, it’s possible with the pre_get_users hook.

In WordPress, though, there’s a handful of pieces of data that you’ll need to work with this hook. Namely:

  • the meta key off of which you want to read the information,
  • how you want to order the query,
  • and how to set up the meta query.

Additionally, if you just want to run the query on the All Users page, it’s helpful to prevent the query from running except for where you want it.

Continue reading
« Older posts Newer posts »

© 2023 Tom McFarlin

Theme by Anders NorenUp ↑