How to search block fields

the content of blocks just goes into wp_posts.post_content, as it always has.

@sterndata,

Thank you, I will look into that and learn it…..

The WP_Query search argument (“s” query var) is what searches post content using the LIKE SQL operator. It also searches post titles for the same value. If that’s a problem, you’d need to alter the WHERE clause through a filter.

Thanks @bcworkz for your input.

With custom fields I can do a wp_query search say for:

Field name = City, value = “Chicago”
AND
Field name = Size, value > 1000

Am I correct in thinking that:

If I have a paragraph block labeled City and a post has the value “Chicago” for this block, and I have another paragraph block labelled Size, and the post has a value of 2000, then all that information, ie the labels and values are stored in one row in the database?

I believe this would make it hard to do an AND query like I could with custom fields…..

Yes. Blocks are delimited by HTML comments, as part of the post content. They are not fields or entities, in any sense.

Thank you for confirming that @sterndata

I was going to set up a test site and see how it all works, so your input is very helpful since now I dont have to do that 🙂



Source link