WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Count number of posts with two perso fields

[Resolved] Count number of posts with two perso fields

  • Hello,

    I try to count the number of posts which have two specific fields:

    <?php
          $test_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->posts a WHERE EXISTS (SELECT meta_id FROM $wpdb->postmeta WHERE post_id = a.ID AND meta_key = 'blablabla') AND EXISTS (SELECT meta_id FROM $wpdb->postmeta WHERE post_id = a.ID AND meta_key = 'test'", $meta_key));
          echo '' . $test_count . '';
          ?>

    but nothing appears (and there is no error) :/

  • The topic ‘[Resolved] Count number of posts with two perso fields’ is closed to new replies.