Created
September 16, 2014 15:31
-
-
Save pietromalerba/c13328dc49e34116adcd to your computer and use it in GitHub Desktop.
Order Fields (advanced custom fields)
This file contains hidden or 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 | |
$fields = get_fields(); | |
//echo "<pre>".var_dump($fields)."</pre>"; | |
$scheda_immobile_valori = array(); | |
if( $fields ) | |
{ | |
//echo '<ul class="lista-dettaglio">'; | |
foreach( $fields as $field_name => $value ) | |
{ | |
// get_field_object( $field_name, $post_id, $options ) | |
// - $value has already been loaded for us, no point to load it again in the get_field_object function | |
$field = get_field_object($field_name, false, array('load_value' => true)); | |
$scheda_immobile_valori[] = $field; | |
$nome_campo = str_replace("_"," ",$field_name); | |
//echo '<li>'; | |
//echo '<div class="nome">' . $nome_campo . '</div>'; | |
//echo '<div class="valore">' . $value . '</div>'; | |
//echo '</li>'; | |
} | |
// echo '</ul>'; | |
} | |
function compareOrder($a, $b) | |
{ | |
return $a['order_no'] - $b['order_no']; | |
} | |
usort($scheda_immobile_valori, 'compareOrder'); | |
// echo "<pre>"; | |
// var_dump($scheda_immobile_valori); | |
// echo "</pre>"; | |
?> | |
<ul class="lista-dettaglio"> | |
<?php foreach ($scheda_immobile_valori as $key => $imm) { | |
if (!empty($imm['value'])) { | |
echo '<li>'; | |
echo '<div class="nome">' . $imm['label'] . '</div>'; | |
echo '<div class="valore">' . $imm['value'] . '</div>'; | |
echo '</li>'; | |
} else { | |
} | |
} ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment