I have a post type
Issue, that has meta values in form of associative arrays (that are saved as serialized strings to database). They look somewhat similar to this:
[article_reviews] => Array (  => Array ( [title] => Article 1 [url] => http://itvar.dev/2015/11/fenicka-kolonizace-s-moreplavci-v-rudem/ [authors] => Author 1, Author 2 [rubriky] => Category 1 ),  => Array ( [title] => Article 2 [url] => http://itvar.dev/2015/11/milos-vorac-nebrat-ceske-slovo-nadarmo/ [authors] => Author 3 [rubriky] => Category 2 ) ), [article_essays] => Array (  => Array ( [title] => Article A [url] => http://itvar.dev/2015/11/example-example [authors] => Author 1, Author B [rubriky] => Category A ),  => Array ( [title] => Article B [url] => http://itvar.dev/2015/11/example-example [authors] => Author C [rubriky] => Category B ) )
The problem is I need to search post type
Issue by this data. That means I need to build a
tax_query, that can search in associative arrays. Somewhat similar to this:
$search_query = 'Author 1'; $args = array( 'post_type' => 'issue', 'meta_query' => array( array( 'key' => 'article_reviews', 'value' => $search_query, 'relation' => 'LIKE' ), array( 'key' => 'article_essays', 'value' => $search_query, 'relation' => 'LIKE' ) ) ); // should find this post, because $article_reviews, $article_essays
This is already answered - for example here - as impossible. But as I don't see any way around the problem I'm trying to solve, I would like to ask anyway. And I hope, that this question provide some value for anyone else with similiar situation as I have.
I am building a website for a magazine about literature. 25% of the content from print issue gets to be online, 75% stays in print only. However each Issue (custom post type
issue) comes with a list of all 100% articles (meta fields
articles_essays, etc.; 25% clickable, 75% not) that needs to be searchable, so the web visitor will find the specific issue containing
On back-end, I currently use metabox with repeatable fields (noone can really now, if there will be 2 or 20 reviews in current issue), that save data as associative arrays.
I am very much opened to alternative solutions, but:
- "just splitting the array" as linked question suggests is not really an option for me, as data for
Article 1etc. need to be "glued" together somehow
- I would prefer to preserve the arrays, so I would not have to make brutal changes to my back-end. If there really are no ways around that, than ok.