【问题标题】:CF7 Flamingo get messages from specific formCF7 Flamingo 从特定表单获取消息
【发布时间】:2020-10-04 19:28:22
【问题描述】:

我如何从某个表单中获取消息?

有了这个我可以得到所有的入站消息:

<?php
        
    $args = array(
            'post_type' => 'flamingo_inbound',
            'post_status' => 'publish'
    );
    
    $query = new WP_Query($args);
    
    if( $query->have_posts() ){
        while( $query->have_posts() ){
            $query->the_post();
            
            echo '<article>';
            echo get_the_title();
            echo '</article>';
        }
    }
    wp_reset_postdata();

?>

但我只想显示当月特定表单中的消息。我在谷歌和这里搜索,但我找不到任何例子或任何东西,所以我希望有人知道。

【问题讨论】:

    标签: php wordpress contact-form-7 wordpress-flamingo-plugin


    【解决方案1】:

    我已经做了一个解决方案,也许不是最好的 php 写作,但它确实有效:

    <?php
        $currentmonth = date('m');
    
        $args = array(
                'post_type' => 'flamingo_inbound',
                'post_status' => 'publish',
                'monthnum' => $currentmonth
        );
    
    
        $query = new WP_Query($args);
    
        if( $query->have_posts() ){
            echo '<ul>';
            while( $query->have_posts() ){
                $query->the_post();
                
                $results = get_post_meta( get_the_ID() );
    
                foreach($results['_meta'] as $result) {
                
                    $normaldata = unserialize($result);
                    
                    if ($normaldata['post_id'] == '1234') { // The id of the post where the form is send from
                        $title = get_the_title();
                        echo '<li>' . $title . '</li>';
                    } else {
                      
                    }
                }
            }
            echo '</ul>';
        }
        wp_reset_postdata();
    
    ?>
    

    【讨论】:

      猜你喜欢
      • 2020-06-29
      • 2019-11-02
      • 1970-01-01
      • 2012-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多