Is it possible to sort all the data in the table of WordPress, with the function get_post_meta() ? or may be I need to implement another function or algorithm. Here's the code
$data = get_post_meta(parameter a, parameter b);
echo '<table id="mi-careerform-table" cellspacing="0" class="widefat fixed" style="font-family: verdana; font-size: 12px; letter-spacing: -1px;">';
echo '<tr>';
echo '<th width="15%">Name</th>';
echo '<th width="10%">Company</th>';
echo '<th width="15%">Email</th>';
echo '<th width="15%">Phone</th>';
echo '<th width="55%">Message</th>';
echo '</tr>';
foreach($data as $item){
$field = json_decode($item);
echo '<tr>';
echo '<td>'.$field->name.'</td>';
echo '<td>'.$field->company.'</td>';
echo '<td>'.$field->email.'</td>';
echo '<td>'.$field->phone.'</td>';
echo '<td>'.$field->message.'</td>';
echo '</tr>';
}
echo '</table>';
I don't know what exactly you want to do with your code but in WordPress there is a class wp_query
. You can pass arguments and order your posts or your custom codes by date.
$query = new WP_Query( array ( 'orderby' => 'post_date', 'order' => 'DESC' ) );
See here for more info WP_QUERY .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.