Tag Archives: Search

Create Additional Search Keywords for Your Gutenberg Editor Blocks

While working on my Gutenberg Editor Development Course I stumbled upon a cool feature for Gutenberg Blocks that let’s someone to find your block using words not found in the title of your block.

Searching for Blocks in Gutenberg

One of the easiest ways to find a specific block in Gutenberg is by using the search field.  By default, if your title has a keyword someone searches for, it will show your block in the results.

Sometimes though, we want our block to show for keywords that are not included in our title.

gutenberg-search-for-block-feature

Here is an example of searching for “Image” and receiving multiple matching blocks

You can see in the example above that if we search for an “Image” block we get blocks that do not have “Image” in the title.

This is accomplished using the “keywords” parameter when registering your block.

Using the Keyword Setting When Creating a Block in Gutenberg

When you create a block using registerBlockType() you can set a parameter called “keyword.”  This parameter takes an array of words that if searched for, will include your block in the results.

custom-keyword-gutenberg-block.png

Custom keyword allows block to be searched for using keywords not found in the block title

In the example above we have added extra keywords to a custom block.

Here is the code to make this work.  (Notice we are also escaping them using the wp.i18n library for localization).

This allows us to have our block show up for the search terms “zac,” “fire,” and “fuego,” which are not found in our block title.

I would suggest looking at what keywords the default WordPress blocks use and leverage some of those keywords in your blocks.

Learn More About Gutenberg Development

If you would like to learn more about creating custom blocks or developing with Gutenberg in general, please check out my Gutenberg Development Course!

WordPress Database Search and Replace with WP CLI

While working locally on a new site I realized that all of the image URLs were busted.  Super happy to test out using the WP CLI search-replace feature for the first time to find out it works great!

wp search-replace oldurl.com newurl.com

Back in the old days I would use plugins like the Search and Replace plugin for this sort of thing just to avoid having to login to phpMyAdmin.  Oh the days of GUIs 😉

Really enjoying working with WP CLI.  If you haven’t tried it out yet, check out our Treehouse course on Modern WordPress Workflow.

WP Seek WordPress Search Engine API

I was happy to stumble across the site wpseek.com, which works as an all things WordPress search engine.

What really impressed me though is their API, which let’s you do things like get specs on a specific function or a list of all WP functions.

For example using the following URL http://api.wpseek.com/?method=wordpress.getfunction&s=the_title will return a JSON object with the basic Codex info on the plugin.

I don’t see a way to get info like WP_Query, but this is still a cool resource if you’re trying to pull together some simple docs on the fly.

Thanks to Oliver Schlöbe for your great work!

Search the WordPress Codex from the Chrome Address Bar

Chrome has a setting that lets you use a shortcode in the address bar to search a site. If you go into Settings > Search > Manage search engines and scroll down to “Other search engines” you will likely see a list of sites setup with shortcodes.

Screen Shot 2013-02-04 at 9.56.48 AM

I use the shortcode wpcodex to search the WordPress Codex. Enter in the following to the bottom of the list of Other search engines:

Once this is done you should be able to type wpcodex into the address bar and get this:

Screen Shot 2013-02-04 at 10.00.45 AM

When you hit enter for that query it will take you straight to the codex page for WP_Query.

A very helpful shortcut for WordPress theme and plugin developers!