Quantcast
Channel: Toolset » All Posts
Viewing all articles
Browse latest Browse all 20145

Repeating Fields with php (sorted)

$
0
0

I am using a Texterea Custom Field als repeating field and want to render all custom field key values in the order I defined.

I tried:

		$features = get_post_meta($post->ID,'wpcf-features',false);
		if (!empty($features )) {
			echo '<h3 id="features"><a href="#features">Features</a></h3><ul>';
			foreach($features as $feature => $value) {
			  echo '<li>'.$value.'</li>';
			}
			echo '</ul>';
		} ?>	

But noticed the sorting is broken and each value is listed some kind of random.

I found this here in the forum

			<?php echo '<ul><li>'.(types_render_field( 'features', array( 'raw' => 'true' , 'seperator' => '</li><li>') )).'</li></ul>'; ?>

Which lists values in the correct sorting, but ignores the "<li></li>" seperator.

How to render my list correct in my theme using php?


Viewing all articles
Browse latest Browse all 20145

Trending Articles