Order articles posts by custom field
-
Dear,
I would like to switch my joomla site to wordpress but I am facing a problem.
I added a custom field with ACF (Advanced Custom Fields)I would like to sort my posts by date of the event and not by date of publication.
my custom field is: start event
I added the get-post in my file
wp-content> theme> template_child> functions.php$posts = get_posts(array( 'post_type' => 'event', 'posts_per_page' => -1, 'meta_key' => 'start_event', 'orderby' => 'meta_value', 'order' => 'DESC' )); if( $posts ): ?> <ul> <?php foreach( $posts as $post ): setup_postdata( $post ) ?> <li> <a>"><?php the_title(); ?> (date: <?php the_field('start_event'); ?>)</a> </li> <?php endforeach; ?> </ul> <?php wp_reset_postdata(); ?> <?php endif; ?>
but it doesn’t work.
Can someone tell me which code to paste and where because I have no control over coding.
Thanks a lot!!!!
The page I need help with: [log in to see the link]
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Order articles posts by custom field’ is closed to new replies.