I Set Up WordPress 7.0 Locally and Tried Out AI Client

Recently, I had the chance to work with WordPress for the first time in a while.

So, for this post, I decided to set up WordPress 7.0 in a local environment and try out AI Client for myself.

What Is the “AI Client” in WordPress 7.0?

AI Client is a system designed to make it easier to use AI services from within WordPress and plugins.

Until now, when using AI from a plugin, it was necessary to implement API connection processes and other tasks for each AI service used.

By using the AI Client, you can access a common framework for working with AI from within WordPress.

In this article, we’ll try using this system in practice.

Setting Up WordPress 7.0 Locally

This time, we’ll test it in a local environment.

We’ll be using “Local.”

Since it makes it easy to set up a WordPress testing environment, it’s useful for experiments like this one.

First, launch Local and create a new WordPress site.

For this post, I’ve named the site “wp-ai-test.”

For this test, we are using WordPress 7.0.3.

Trying Out the AI Client

Creating a Plugin

When you press the button, it asks the AI a specific question and displays the answer.

I’m going to create a small plugin called…

Open the wp-ai-test folder you created in Local.

Inside the “app/public/wp-content/plugins” directory in WordPress,

Create a folder named “wp-ai-client-test.”

Inside that directory, create a file named “wp-ai-client-test.php.”

Initial plugin code

First, let’s get WordPress to recognize it.

I will enter the information as described above and save it.

In the WordPress admin panel, go to “Plugins” → “Installed Plugins.”

“WordPress AI Client Test” will appear in the list of plugins.

Add “AI Client Test” to the Admin Panel

Next, we’ll create a dedicated page in the admin panel.

Add the code to the file from earlier.


Once you save and refresh the admin screen, “AI Client Test” will appear in the left-hand menu.

Make sure to “activate” the plugin.

Add a “Ask AI” feature

In this session, we’ll set it up so that when the “Ask AI” button is clicked, a fixed question is sent to OpenAI.

Add the processing to the ai_client_test_page() function.

We’ll also make a few changes to the form.

Save and Run

When I clicked the “Ask AI” button, the answer to my question was displayed.

Summary

Given the name “AI Client,” I had imagined the implementation would be a bit more complex, but I was able to call the AI with some simple code.

AI Client is not a feature that provides AI itself, but rather a platform for using AI within WordPress. To actually create useful features, you’ll need to integrate it using plugins or similar methods.

Since WordPress allows you to add features through plugins, I felt that combining it with AI Client could lead to the implementation of various AI features in the future.

Going forward, I’d like to try out features that are useful for actual WordPress management, such as article summaries and title generation.

Stay tuned for the next Engineer Blog post.