You need to use the PHP version of the query: the shortcode version is quite limited in comparison, mostly due to the limitations, whoops I mean FEATURES of the WordPress shortcode syntax.
I’m not sure what you mean by “display results from one of the values”, but I think you probably need to do a LIKE comparison — the shortcode only lets you do an EQUALS comparison. In php:
<?php
// in a theme file far, far away....
$Q = new GetPostsQuery();
$args = array();
$args['post_type'] = 'resource';
$args['location']['like'] = '"National"'; // <-- note the quotes here
$results = $Q->get_posts($args);
foreach ($results as $r) {
// ... etc...
}
?>
Because CCTM stores multi-values as JSON arrays, you have to compare against the double-quotes to properly delimit your values, otherwise a term like “National” might also include results using a term like “National Parks”. Note too that you can name your custom fields: you don’t need to use the meta_key/meta_value syntax.
There are lots of examples in the wiki.
Thanks for your super prompt reply. Yes, a comparison would work nicely.
My main question now, is where do I add this php code? The way I am using cctm is to add “resources” to the DB, then I created posts that I called “views” to display the resources based on the values stored for each custom field. Then using a widget, I created a menu of all those “views”
For example, this is one of the “views”
http://civilrightsteaching.org/books-fiction/
ANd on the right side, you can see the menu of all resources.
Now you’re seeing some of the limits of wordpress. Here’s how I get around them: I create a page (not a post) as my unit here because pages can have a dedicated theme file — copy the page.php file in your theme and give it a unique name in its comment block, e.g. “Template Name: My View”. Then you can select that template when you create a page. Put your PHP in there. That’s how you can connect a page to a specific file containing your specific php.
Thanks again… I’ve created my new template file page-myview.php and added the php code. Of course nothing happens, since I don’t know what to put after this:
$results = $Q->get_posts($args);
foreach ($results as $r) {
// I TRIED ADDING “print $post[‘post_title’];”
}
?>
The summarize-posts shortcode was so easy compared to this php coding 🙁
See the wiki: lots of examples there. https://code.google.com/p/wordpress-custom-content-type-manager/wiki/get_posts_examples
You’re iterating over an array using the $r variable in your case: so you can’t print $post and expect anything to come out of it. Try print $r[‘ID’]; or print $r[‘post_name’]; or print_r($r); to get a full dump of every attribute available to you. Sorry, I can only offer some pointers here — some PHP knowledge is required and it’s not practical/efficient/sensible for me to repeat a PHP 101 course inside my docs.
Thanks so much for your help.
With some study and time I hope to solve this issue.