Custom Fields in Reverse Order
-
Hi, I have searched through the forums so hopefully this hasn’t been covered.
I am using custom fields in a portfolio page listing 12 previous websites I have designed as a thumbnail that links to a detailed case study page. I wish to have my most recent work at the top of the page and the rest in chronological order. This works fine when setting up the page as when adding the custom field I simply list the most recent first and so on.
However when I come to list a new piece of work, I am gonna have to cut and past all of the older work down the list as when adding new fields it appears a the bottom of the list not the top.
The simplest solution would be to list them oldest first and keep adding to the list at the bottom. Then when I display them on the page they should be in reverse order. How do I do this? Here is the code I use at the moment in my page template that lists them in the order they appear in the custom fields:
<?php $cs_href = get_post_custom_values("cs_href"); ?> <?php $cs_image = get_post_custom_values("cs_image"); ?> <?php $hover_text = get_post_custom_values("hover_text"); ?> <?php for($i = 0; $i < count($cs_image); $i++) {?> <li><a href="<?php echo $cs_href[$i] ?>"><p><?php echo $hover_text[$i] ?></p><img src="<?php echo $cs_image[$i] ?>" alt="<?php echo $hover_text[$i] ?>" width="179" height="105" /></a></li> <?php } ?>
I freely admit to not being a php guru, I am a designer not a coder. How do I change the ‘for’ statement or is there a better solution?
- The topic ‘Custom Fields in Reverse Order’ is closed to new replies.