Shortcode with a foreach and arguments

Here is your problem: foreach ($files[0] as $file) { There is no $files variable, so there is nothing to loop through. You can’t pull variables out of thin air and expect PHP to understand your intent. Computers are very literal, in the most extreme sense. They can’t intuit what you meant, or want. This code … Read more

Display all taxonomy terms, add class if term applies to current post

I was able to put this together from a similar question I found. If anyone else needs it: <?php $terms = get_terms( array( ‘taxonomy’ => ‘features’, ‘hide_empty’ => false ) ); if (!empty($terms) && ! is_wp_error( $terms )) { echo ‘<section>’; foreach ($terms as $term) { $class = has_term( $term->term_id, ‘features’ ) ? ‘active’ : … Read more

Missing image in gallery shortcode in custom feed

The problem was in additional symbols &#8221 in $attr[‘ids’] array. So I’ve changed: $atts[‘include’] = str_replace(array(“&#187;”,”&#8243;”,”&#8221;”), “”, $atts[‘include’]); $atts[‘orderby’] = str_replace(array(“&#187;”,”&#8243;”,”&#8221;”), “”, $atts[‘orderby’]); $atts[‘order’] = str_replace(array(“&#187;”,”&#8243;”,”&#8221;”), “”, $atts[‘order’]); $atts[‘exclude’] = str_replace(array(“&#187;”,”&#8243;”,”&#8221;”), “”, $atts[‘exclude’]); And now everything ok.