List custom field values in alphabetical order without repetition
-
03-11-2019 - |
Question
The function below lists the custom fields as in this example:
- Frank Capra
- Alfred Hitchcock
- Woody Allen
- Woody Allen
- Frank Capra
- Pedro Almodóvar
- Pedro Almodóvar
I introduce the values in alphabetical order and without repetition. Eg:
- Alfred Hitchcock
- Frank Capra
- Pedro Almodóvar
- Woody Allen
This is the code:
<?php
$movie_reviews = get_posts('numberposts=-1&orderby=post_name&order=ASC');
foreach($movie_reviews as $post) : setup_postdata($post);
?>
<li>
<?php $director = get_post_meta($post->ID, "director", $single = true);
if($director !== '') {
echo $director;
} ?>
</li>
<?php endforeach; ?>
</ul>
Is this possible? Grateful for any help.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange