I have a post type and a table in the database that I display with the following code. The code works well!
But I want this list sorted by date.
My database table:
|id |
|message_author |
|message_date |
|message_update |
|message_title |
|message_status |
|message_content|
<?php
global $wpdb;
$user_id = get_current_user_id();
$message_table = $wpdb->prefix . 'messages_hb';
$messages = $wpdb->get_results("SELECT * FROM {$message_table} WHERE message_author = $user_id AND message_status = 'reply' ORDER BY message_update DESC ");
$notices_query = array('post_type' => 'notice', 'numberposts' => 5);
$notices = get_posts($notices_query);
$output1 = array();
$output2 = array();
if ($notices) {
foreach ($notices as $notice) {
$output1[] = '<li><a href="">' . $notice->post_title . '</a></li>';
}
}
if ($messages) {
foreach ($messages as $message) {
$output2[] = '<li><a href="">' . $message->message_title . '</a></li>';
}
}
$output = array_map(null, $output1, $output2);
foreach ($output as $items) {
$items = array_filter($items);
foreach ($items as $item) {
echo $item;
}
}
?>