get_row_layout()

Description

This function returns the current layout (string) within a the_flexible_field() loop. A flexible content field may hold many different layout options which can be placed on a page in any order.

It is necessary to use this function in your template to decide what code to write and which sub fields to call.

Requirements

Parameters

This function has no parameters

Usage

<?php while(the_flexible_field("content")): ?>

	<?php if(get_row_layout() == "paragraph"): // layout: Content ?>

		<div>
			<?php the_sub_field("content"); ?>
		</div>

	<?php elseif(get_row_layout() == "file"): // layout: File ?>

		<div>
			<a href="<?php the_sub_field("file"); ?>" ><?php the_sub_field("name"); ?></a>
		</div>

	<?php elseif(get_row_layout() == "featured_posts"): // layout: Featured Posts ?>

		<div>
			<h2><?php the_sub_field("title"); ?></h2>
			<?php the_sub_field("content"); ?>

			<?php if(get_sub_field("posts")): ?>
				<ul>
				<?php foreach(get_sub_field("posts") as $p): ?>
					<li><a href="<?php echo get_permalink($p->ID); ?>"><?php echo get_the_title($p->ID); ?></a></li>
				<?php endforeach; ?>
				</ul>
			<?php endif; ?>

		</div>

	<?php endif; ?>

<?php endwhile; ?>