OK, so I figured out what I was doing wrong.
What I had originally tried was the foreach
on its own and then placing the gallery output below it. I also tried wrapping the foreach
around the entire gallery output.
To get it working, I needed to wrap the foreach
around the output of the itemtag in the gallery shortcode:
$terms = wp_get_post_terms( $id, 'media_category', array( 'fields' => 'all' ) );
$output .= "<{$itemtag} class="gallery-item {$orientation}";
foreach ( $terms as $term ) {
if ($term->parent != 0) {
$term = $term->slug;
$output .= " {$term}";
}
}
$output .= "" itemprop='associatedMedia' itemscope itemtype="http://schema.org/ImageObject">";
Related Posts:
- Add Image Size for one Media Category Only
- Retrieve Image from Media Library by it’s category
- Category view with contents of [gallery]s shown
- Image Upload Custom Form Field for Category and Custom Taxonomy
- Category page with gallery for each post
- How to create a photo gallery that can be filtered by the image categories
- Woocommerce get category image full size
- Filter by post category in Media Library
- Default WP Gallery – show only galleries of a certain category
- Way to force media uploader use custom image size
- Use Media Library to manage galleries like Nextgen (with folders, albums, collections, tags, categories, terms…)
- categories on attachment page
- Can I attach an image to a different post?
- Connecting WordPress gallery to custom categories (taxonomy)
- Taxonomies for WordPress Media Library [duplicate]
- Display the featured image from the last post
- Extract image url associated to a category
- Show category images on single product page and product overview page
- Link Attachment Image to Category
- Change thumbnail image depending product category
- category image taxonomy
- categories on attachment page
- get_post_meta not working on category.php
- Original image not saving?
- Redirect to another page using contact form 7? [closed]
- Random Featured Image Based on Category
- Show posts in “image” format when viewed in category page, but with comments in blog
- Category images are not displaying in WordPress
- How do you use the featured image of the most recent post in a category as the background image
- Need to echo category id in multi-dimensional array
- How to link a PDF file to a category URL
- How to add image for all posts associated to specified category?
- How to display WooCommerce category image in my category page banner as a background?
- How to make product image inherit from category image
- How to display categories image in loop homepage WordPress
- Change background image page header overlay for each category
- Icon images across multiple categories
- Media Library Category Exclude Tree
- Media Library Categories
- How to relocate images
- ACF Gallery with Media Categories – how do display categories and sort
- In a shared site, how to get products in a category from one site to another?
- Display one post on category.php: Wrong featured image
- Media Library filter returns undefined function get_current_screen
- Image menu showing categories in page
- Featured image for links and categories
- Get all first images of posts in same category
- How to Organize my Photo Albums?
- Add category image before post title on homepage
- how do i set an image for a category in admin panel
- How to link images of one WP site to another WP site?
- Images as Categories
- Child Category Conditional Question
- Latest updated categories list query, exclude one from displaying
- Deleting a category from WordPress admin does it remove it completely from the database?
- Style a category from category list
- Adding a page summary to a specific page
- How to display post in custom file not in archive file?
- Getting the first parent of a hierarchical term
- Why is my sub-category template showing the wrong posts
- How the posts and categories connected each other in wp 4.1.1?
- Theme for subcategories
- Hide a category of posts from main blog, and only show in category view
- Display category title and three latest post inside the category
- ACF no print data [closed]
- How to restrict the amount of categories/post tags/terms for a post type post
- WP_Query – using category__and when one of the categories is 0
- More efficient way to list posts by category [duplicate]
- Same menu for different taxonomies to reach different content
- Multiple categories for one menu item?
- Adding a block with query in homepage
- How to get category id’s which are added in main menu?
- Query posts by views on category page
- Change categories count to include media attachments
- How to Sync Menu, Widgets and other masters from Main Website to its Sub Site
- How to schedule categories?
- Template for product-category page [closed]
- Using categories with pages
- Show next post in same category but start from the latest
- Tags Instead of Category
- Show category meta in loop on homepage
- How set all posts in wordpress in one category
- Link from navbar to categories
- Add Date & Author Meta to Category Archive Page
- A dropdown with checklist
- How to get nav to show current_page_parent class when on regular post (not blog), differentiated by category
- Showing HTML if Post is In Certain Taxonomy Term
- How to get selected taxonomy or category ID if using custom walker?
- WordPress showing wrong category name
- How to exclude posts from category posts count
- How to change the value “uploaded to” in the media library (WordPress 4.0)
- Custom meta boxes ID prefix showing on first category but not others
- Exclude category from foreach loop
- Cannot filter categories by parent category
- Add posts of a certain category to a page
- Redirect year month day postname permalink structure to category postname structure
- Add code to header based on category for specific posts?
- Show all sub categories?
- ID of last created category
- Page that links to category content