Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function custom_dashboard_contact_widget(){
- wp_add_dashboard_widget(
- 'dashboard_widget_recent_contact',
- __('Messages via formulaire de contact', 'theme'),
- 'custom_dashboard_contact_widget_content',
- $control_callback = null
- );
- }
- add_action('wp_dashboard_setup', 'custom_dashboard_contact_widget');
- function custom_dashboard_contact_widget_content() {
- $args = array(
- 'post_type' => 'contact',
- 'orderby' => 'date',
- 'order' => 'DESC',
- 'numberposts' => 5
- );
- $contacts = get_posts($args);
- echo '<ol id="dash_widget_contacts">';
- foreach ($contacts as $index=>$contact) {
- $title_array = explode(' | ', $contact->post_title);
- $name = $title_array[0];
- $email = $title_array[1];
- $message = $contact->post_content;
- echo '<li>';
- echo '<h4>';
- echo $name . ' <small><em><a href="mailto:' . $email . '">' . $email . '</a></em></small>';
- echo '</h4>';
- echo '<p>' . $message . '</p>';
- echo '</li>';
- }
- echo '</ol>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement