If you wanted to display the direct associations against a category, you would need to retrieve the association from the database and build a post collection manually using the IDs retrieved.
To expand on Bens comment, the helper Fishpig_Wordpress_Helper_Associations
can get associations for you.
In here you'll find the function;
public function getAssociations($type, $objectId, $storeId = null)
If you step through this file you'll be able to figure out what you need to do, but for ease please an example of it in use below;
$_helper = Mage::helper('wordpress/associations');
$_category = $this->getCurrentCategory();
$_associations = $_helper->getAssociations('category/category',$_category->getId());
$_collection = Mage::getResourceModel('wordpress/post_collection')
->addIsPublishedFilter();
This will return an array where keys are the WP category IDs and the value is its position within Magento.
Next you'll need to flip the keys into values.
Warning Don't use array_flip
! If you have categories with the same position only the last oe with the same value will be saved.
Solution It's a little dirty, but you can then loop through and rebuild the array to be used at a later date;
if($_associations && $_collection->getSize()){
$_wpIds = array();
foreach($_associations as $_id => $_position){
$_wpIds[] = $_id;
}
}
You can filter your collection using the function addCategoryIdFilter($categoryId)
.
Unfortunately, it seems this doesn't accept arrays and if it were to be applied multiple times to your collection then it will return false. Sadly, it seems there isn't a function within the module where you can filter a collection by an array of category IDs.
In an ideal world, the ID filter should accept both string and arrays, and if an array you should be able to define an AND
/OR
parameter. Possibly something for a future release ;)