Last active
October 19, 2022 22:23
-
-
Save kodie/cbe1ed24e4a06d9794081628a0b1d310 to your computer and use it in GitHub Desktop.
A function for WordPress that returns true or false depending on if a post's $field_name ACF field contains the $layout_name(s) flexible layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Returns true or false depending on if a post's $field_name ACF field contains the $layout_name(s) flexible layout | |
function have_flexible_layout($field_name, $layout_name, $post_id = false) { | |
if (function_exists('have_rows') && have_rows($field_name, $post_id)) { | |
while (have_rows($field_name, $post_id)) { | |
the_row(); | |
if (in_array(get_row_layout(), (array) $layout_name)) { | |
reset_rows(); | |
return true; | |
} | |
} | |
reset_rows(); | |
} | |
return false; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment