WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Count number of posts with two perso fields (1 post)

  1. csseur3
    Member
    Posted 5 years ago #

    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) :/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.