mandiwise / isotope-posts

[RETIRED] This plugin allows you to use Metafizzy's Isotope javascript plugin to display feeds of WordPress posts with a simple shortcode. Works with custom post types and custom taxonomies too.
GNU General Public License v2.0
55 stars 17 forks source link

PHP warning when Add Filter Menu is set to No #3

Closed jengalas closed 10 years ago

jengalas commented 10 years ago

Nice plugin! This is the best implementation of Isotope I've found for WordPress, at least for my needs—thank you for including custom post types and taxonomies!

For the case when Add Filter Menu is set to No, I see the following in the class attribute of my <li>s:

<br /> <b>Warning</b>: Invalid argument supplied for foreach() in <b>[my_site]/wp-content/plugins/isotope-posts/isotope-posts.php</b> on line <b>179</b><br /> iso-post isotope-item

I think you want to check get_the_terms( $isoposts->post->ID, $menu_tax ) before using it in the foreach on line 179.

Perhaps $getterm = get_the_terms( $isoposts->post->ID, $menu_tax ); and then the following changes to the code on line 179: <li class="<?php if ( $getterm && !is_wp_error ( $getterm ) ) { foreach ( $getterm as $term ) echo $term->slug.' ';} ?>iso-post">

mandiwise commented 10 years ago

Whoops! Thought I pushed a fix for this on my last commit. Actually did it this time... the php warning should be gone in in v1.1.3.

Thanks for bringing this to my attention and glad you like the plugin.