Support

Account

Home Forums Add-ons Flexible Content Field Search for Pages that have Particular Flexible Content Layouts

Helping

Search for Pages that have Particular Flexible Content Layouts

  • Hey folks,

    I have a Flexible Content field that is reused on all pages of my site. It is a list of about 20 layouts or so, just a bunch of building blocks for the site.

    I was wondering if there is a way to search for pages in the back end that have a particular layout from that list. For example, some pages are using the “Video Grid” layout selection, but some aren’t. Can I filter down the pages to ones that have used it?

    The reason I ask is that I want to make some theme modifications for particular layouts, and I want to be able to test each occurrence of that layout so I can make sure nothing broke. I’d rather not have to go through EVERY single page looking for the ones that have a video grid.

    Thanks in advance and let me know if this needs any clarification.

  • In the database in the post_meta table the meta_key (field name) of the flexible content field, the value stored is a serialized array of layout names.

    If we were going to do a WP_Query using the meta value the meta_query would look something like this

    
    meta_query = array(
      array(
        'key' => 'flex_field_name',
        'value' => '"flex_layout_name"',
        'compare' => 'LIKE'
      )
    )
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Search for Pages that have Particular Flexible Content Layouts’ is closed to new replies.