2017-09-27 6 views
0

데이터베이스에서 이름과 이메일을 가져 와서 내 웹 사이트의 프런트 엔드에 표시하려고합니다. 나는 많은 대본을 시험해 보았고, 플라밍고 포럼을 보았다. 그러나 couldnt는 해결책을 발견한다.meta_key를 사용하여 Flamingo plugin의 데이터베이스에서 이메일과 이름을 가져옵니다.

모든 데이터는 wp_postmeta 중 하나에 저장됩니다. 다양한 postmeta가 있기 때문에 flemingo postmeta를 어떻게 구별합니까? 어떻게 flemingo를 끌어 당길 수 있습니까 _field_fullname_from_email? 다음은 데이터베이스가 사전에

INSERT INTO `wp_postmeta` (`meta_id`, `post_id`, `meta_key`, `meta_value`) VALUES 
(5874, 1438, '_field_fullname', 'Jason'), 
(5875, 1438, '_field_phone', '04112343'), 
(5876, 1438, '_field_email', '[email protected]'), 

감사 힙 덤프입니다.

https://wordpress.org/plugins/flamingo/

답변

0

내가 도움이 될 최신 이메일을 보여주기 위해 대시 보드 위젯을 만든

//Add custom dashboard widget 

function my_custom_dashboard_widgets() { 
wp_add_dashboard_widget('my_show_latest_emails', 'Latest Emails', 
'my_show_latest_emails'); 
} 
add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets'); 


//function to get emails 
function my_show_latest_emails() { 

echo '<div id="activity-widget">'; 

$args = array(
    'numberposts' => 10, 
    'offset' => 0, 
    'category' => 0, 
    'orderby' => 'post_date', 
    'order' => 'DESC', 
    'include' => '', 
    'exclude' => '', 
    'meta_key' => '', 
    'meta_value' =>'', 
    'post_type' => 'flamingo_inbound', 
    'post_status' => 'publish', 
    'suppress_filters' => true 
); 

$recent_emails = wp_get_recent_posts($args, ARRAY_A); 

if($recent_emails) 
{ 
    echo '<table><thead><th>Date</th><th>Email</th></thead><tbody>'; 
    foreach($recent_emails as $email){ 
     echo '<tr>'; 
     echo '<td>' . $email->post_date . '</td>'; 
     echo '<td>' . $email->post_title . '</td>'; 
     echo '</tr>'; 

    } 
    echo '</tbody></table>'; 
} 

if (!$recent_emails) { 
    echo '<div class="no-activity">'; 
    echo '<p class="smiley"></p>'; 
    echo '<p>' . __('No activity yet!') . '</p>'; 
    echo '</div>'; 
} 

echo '</div>'; 
}