Probably your hosting server has a different and older version of php so this syntax is not supported.
The above syntax is implemented in PHP 5.4.
You have to do it like this:
$category = get_the_category($id);
echo $category[0]->slug;
Source:
Related Posts:
- How to create a custom sort for WordPress categories
- Hook when category is added to post
- get_categories for custom post type with a specific custom taxonomy attached
- How to add the category ID to admin page
- Multiple Domain Names – One WP Install (non-Multisite) – Default Each Domain name to Category Archive
- Exclude categories from Loop, queries, widgets, post navigation
- how to use a different domain/subdomain for authors/catagories on single site?
- Sticky posts on home page, search, tag and archives without plugin
- WordPress 1 domain multiple blogs
- Category count inside the link
- One WordPress Install, Two Categories. Each Category Gets a Domain
- Name of last category level for a post
- How to add style to category link?
- WordPress Ordering Problem. How to fix ordering 1-10-100 issue?
- Filtering Children of the “uncategorized” Category out of the Loop?
- how to show posts of category random by session
- Update wordpress post terms programatically
- Remove “Parent” Selection When Adding/Editing Categories?
- Remove Categories and Tags from Admin Dashboard
- Custom category link in wp_list_categories()
- Using widget logic I want to show only a widget on the archive page if there are no posts
- Allow contributors to add categories, but not delete
- Show all posts of sub category in a page like: foo.com/category/subcategory/ using UNCODE Theme
- Replace category titles
- PHP Fatal error: Cannot use object of type WP_REST_Response as array in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
- WordPress categories being called “archives” in google links. How to remove?
- 403 forbidden on one page only
- Show recent posts from one category on a non-WP site
- Multiple Category Search
- Omit specific product categories from WooCommerce shortcode
- Exclude Posts From Specific Category from Next and Previous post links
- how to query posts and auto assign category if post title has keyword
- I want to display posts common in 3 categories [closed]
- Displaying just one new/current post per category in homepage
- How do I share categories across selected sites in a Multisite setup
- Show popular post by category code
- Drop posts from categories in MySql
- Categories in admin interface: can they be collapsible?
- How to append category name to category ID in a form field
- Equivalent to in_category() for subcategories
- query_post order desc
- Limit number of posts on a custom category template – breaking pagination
- list categories based on updated posts [closed]
- How to create a subcategory to a PAGE on WP?
- How can I only display one link rather than many?
- Hierarchical permalink structure for posts showing categories and sub-categories
- how i can hide some category from author admin panel?
- Display posts from a category
- Finding the category id’s on category intersection pages
- how do I use the walker class to display categories in their correct heirarchy?
- Display sibling categories on category page
- Getting the category title / description returns first matching post?
- I want to know how to output child categories related to parent categories
- Allow user to select categories that will display in post loop
- display category list year wise in wordpress
- Echo show_count of categories separately without using wp_list_categories
- Two Sections on Woocommerce Catergory Page [closed]
- Display subcategories in dropdown
- Illegal string offset ‘taxonomy’ in
- Are term_taxonomy_id and term_id the same? [duplicate]
- Display all sub category but one
- Let user select their own category
- SQL query to get posts from multiple categories but not in a category
- Can each user have only access to a private area (his own categories and posts)?
- Pagination breaks on child-categories, works fine on parent-category
- Is the part “category” fixed to an URL to an archive or post?
- How can I use AJAX with check-box categories?
- List Categories By Specified First Character
- the category city made as a subdomain
- Category name for all posts getting assigned to a single random post
- Displaying Single Product Page Parent and Child Category
- WordPress Default Category and Custom Taxonomy Selected Attribute not Working After Searched in wp_dropdown_categories Array
- How to add the .html extension to the category?
- Add filter for specific category only
- How to create category filter on a blog like on the site below?
- How to exclude a category returned by get_categories from function.php?
- Wrong category in URLs accepted like the correct one
- Style a category page the same way as the homepage?
- How to display only sticky posts on category pages?
- Conditional statement: if is_category, append at the end of page
- How to Manage and link certain custom taxonomy?
- Store All Post Categories In Array
- How to add an “All” category to the tag cloud?
- Display Taxonomies in loop with template args
- /blog/ permalink prefix causes category pages to 404
- How to create an array with category ids order by the one that has the most recent post
- Conditional statements based on custom meta value in category archives
- Placement of categories
- Categories Going to different Blog Pages?
- Display only the latest post
- How to structure Multisite sites into categories?
- Change next_post and previous_link to navigate throught parent categories only
- Template files not working for archives and categories
- Multiple Parent Category URLs
- Excluding cateory not working on my site. how to solve this? [closed]
- Get all first images of posts in same category
- What defines a post as portfolio page content?
- How to add location as category?
- Taxonomy term RestApi data 10 rows limitions
- Replace category titles inside RSS feed