Skip to content

WP-CLI Command: wp block type search #212

@TeemuSuoranta

Description

@TeemuSuoranta

This command would search through posts and find instances where block is used.

Likely not using WP_Query but checking in SQL query from post_content would be more performant althoguh WP_Query would be much more extendable.

Example usage:

wp block type search --name=core/accordion

This could lend itself to block styles too:

wp block type search --name=core/image --style=circle

You should be also able to limit post type:

wp block type search --name=core/accordion --post-type=page

And probably limit results:

wp block type search --name=core/accordion --limit=100

As what results this would return I'm a bit unsure.

Often I would like to see table with post id, post title, permalink and maybe post status.

The command wp post list includes example implementation of passing query arguments, return fields and format so it's good benchmark for this.

Use case: Find real examples from a project where certain blocks/block styles are used. This matters when checking styling, when refactoring or when it's safe to remove obsolete blocks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions