Boolean AND logic with TPG Get Posts
-
Hi,
I was looking for a plugin that would let me do boolean AND queries of post categories and I couldn’t find one, but I was able to add two lines of code into the TPG get posts plugin and Boolean AND logic on categories works perfectly!This is TPG version 1.3.8.
In tpg-get-posts/inc/tpg-gp-process.class.php I added thispublic function tpg_get_posts_gen($args = '') { global $id, $post, $more, $more_link_text; //default values passed to get_posts $default_attr = array( 'numberposts' => '100', 'offset' => '', 'category' => '', 'category_name' => '', 'category__and' => '', // <------------ added this line 'tag' => '',
and then in the same file farther down, just above “//Setup params for query” comment I added:
//added this statement if ($r['category__and'] != '') $r['category__and'] = explode (",",$r['category__and']); // End added stuff //setup parms for query
Then in the short code you just use:
[tpg_get_posts category__and=50,22,3,5] // NOTE: IT’S TWO UNDERSCOREs!!
and it works wonders!MMX
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Boolean AND logic with TPG Get Posts’ is closed to new replies.