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
- How would I get a taxonomy/category list inside a Gutenberg block?
- Having Problem On Getting WP Post Gallery Images URL
- Showing all the posts in one page?
- On Category page, How can I get the category ID?
- How to order categories in Woocommerce that are spread over multiple pages? [closed]
- Automatically add product_categories to nav_menu
- Can paginate_links() be customized for a specific category or tag?
- Add Product categories to WordPress menu without losing hierarchy
- How to set up Author archives with sub category URL
- How to change number of items on add new pluggins page from backend?
- Ignoring a category in WP_Query still shows the links in next_post_link()?
- Implementing a tricky wordpress menu (nested categories + thumbnails)
- How can I duplicate categories and tags?
- attachment.php code or tutorial
- How can I add more “filters” to my products? (Categories, attributes, etc.)
- Removing post category base giving Error 404
- Is There a Difference Between Taxonomies and Categories?
- Upload multiple images and insert them into custom html code
- Gallery with thumbnail carousel
- Related Tags not in category
- How to limit the number of images displayed in the media window?
- How to show a list of only categories (exclude subcategories)
- How to list categories in reverse alphabetical order?
- I want to show category name when using [category] shortcode
- How to hide some categories in dashboard
- How to choose the content from a post which is in the right category?
- How to get category id’s which are added in main menu?
- get all categories’ latest post in one query
- Categories show 404 error on multisite installation
- Get Categories of multiple posts
- Show subcategories broken when WP/WC updates
- Display menu in category and sub category
- Show alternative menu based on page template AND post category
- How to change category labels in different colors?
- On main page, in each post, display image depending on post category
- Category next page link not working
- How to display the past events in one of the category?
- How do i replace the title attribute of img tag with the image caption
- Page Type with Category Link
- If I change the taxonomy of a post will it get a new time stamp?
- Display post of current parent category, and in right hand side show child category post
- Category pagination not working in category.php please help me
- Print the associated categories of the current post starting with parent (with option to remove href)
- How to get specific number of category post on a page or category page?
- Use same wordpress category base and tags as the prefix as the post permalink
- Upload to a specific media folder created by FileBird Lite
- Display different sidebar based on search results from one category
- Adding category to existing post (uploaded file)