The answer was found here: http://www.wprecipes.com/how-to-display-category-name-without-link
For my purposes, I needed to define the category function and then call it by name-only inside the php echo
:
<?php
$category = get_the_category($attachment->ID);
echo 'html goes here';
echo ''.$category[0]->cat_name.';
?>
Additionally, to help eliminate space or punctuation in the category name, it can display the slug instead:
<?php
$category = get_the_category($attachment->ID);
echo 'html goes here';
echo ''.$category[0]->slug.';
?>
Related Posts:
- How to add classes to images based on their categories?
- How to add a rel attribute to images that contains their categories?
- Display a list of random terms from custom taxonomy with shortcode
- Display random categories on the front page (Finding and Editing Theme Functions)
- remove links from images using functions.php
- Auto delete WordPress images/thumbnails (all sizes) and featured after X days/hours, or similar?
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Php string not working in WordPress Functions.php (trying to fetch 1st category for each blog that post appears in the sidebar)
- Add class to Categories Widget
- How to Acheive the custom woocommerce category template
- How to set child post categories to parent post categories when updating parent post?
- Assign category using custom field?
- How To Get WordPress Categories Link List?
- Best way to programatically add “rel” attributes to page and post images
- Changing post category from dropdown
- Manipulate Output of wp_list_something: select menu instead of li’s
- What is the “icon” parameter in wp_get_attachment_image_src used for?
- Find first image on paginated post for Pinterest
- Attach parent category template to all subcategories
- How to preserve edits to Name or Slug of term when using wp_update_term on save?
- exclude a category from a search on a specific page
- Get the category name outside of the loop in category.php
- Is it possible to change any of the HTML/URL returned from the_category()
- Insert HTML inside link in a walker
- Custom HTML in specific category single page and its descendant categories
- Can’t check if a post has thumbnail adding filter to get_post_metadata()
- Possible to display shortcode based on the category?
- Unset Category if other Category is unset during post transition
- Select pages by category
- Image rotation fails to regenerate custom sized thumbnail
- Show Primary Category first when I display post categories
- How do I hide or remove ‘Category’ from wordpress breadcrumbs
- Display images that are not in the content
- Ordering posts by publish date not working?
- Move ‘current-menu-item’ class on #adminmenu li from Posts to Pages for Taxonomy Edit Screen
- Hierarchy and access control for Custom Post Types (CPT)
- Create a custom taxonomy that will be used to create and filter markers in a Google Map
- Categories as main menu items and subcategories as nested lists
- Can’t filter wp_get_attachment_link
- Get category URL for current post
- Get ID of first image attached to a post
- Need help “sanitizing” a custom function that pulls category slug into body class
- allow only one post in specific category
- How to stop wordpress from injecting hard-coded style into image attachments with captions
- How to obtain the recent posts without their content in an efficient way?
- Setting a default text for excerpts of a particular category
- Running script based on Category
- Remove a category from a post when saving a new post
- How to fix get_the_category function returning incorrect slug?
- Return category name with & Ampersand doesnt work
- add slug beside name in Admin Category Checklists
- How to hide image-url if no attachment?
- attachment page template? only show attachments for current post?
- Get Comma Seperated Taxonomy Linked Terms and Last Child Separated By “&” Instead Of Comma
- Access category within rss2_head hook?
- What are the meta fields for an attachment?
- issue with if/elseif in_array inside foreach loop display only one post
- Randomizing wp_tag_cloud() in child theme
- add_filter to specific WooCommerce Category
- How to rewrite wordpress search to work on specific category
- Image loading function not working on archive.php template
- Exclude Category ID in function
- Problem with calling custom function in a foreach loop
- Specify multiple categories for custom post template – FATAL ERROR
- “All posts” in the category widget
- Remove attachment page for audio media type only
- How add body_class from wp_termmeta
- How to load several hierarchical categories from functions.php
- How d0 i get the number of attachments in the post
- WordPress Categories: Function using custom SQL to return array of specific category IDs
- Display ACF category image on archive and single template files
- Get slug of current category in functions.php
- How to divide Subcategories into pages of parent category wordpress
- Auto delete content in specific folder inside media library
- Change category display name function
- WP_Query for Attachments not working as expected
- How to update an image attachment’s alt text from a custom field when saving a post?
- Remove the ‘category’ url for one category type
- Custom Function.PHP Code Not Working on One Site
- How do i tweak my wp Post title base on category of the post
- I am trying to set post terms to a custom taxonomy
- how to remove a tag in the_category function
- Menu and category highlighting for a single post
- Why is the term of my current page not returning a slug?
- i can’t use wordpress functions in ajax loaded php file
- Remove all video attachment, both files and post/postmeta from database?
- Graphic before title – Specific Category
- Taxonomy On Index Page
- Custom taxonomy check box now showing up
- different body classes for each category
- Only seems to be displaying one child when there are supposed to be multiple
- How to prevent multiple custom terms from being created
- How To Get WordPress Categories Last Update Date?
- Open image size links in a page instead of direct image link
- Get category id for a custom category and display it in a class
- Set thumbnail from URL, by grabbing image in functions.php
- How to get tags and categories?
- Removing all Category pages with one exception
- Warning: call_user_func_array() expects parameter 1 to be a valid callback
- Disable Attachment Page Except for Category