Two things here, one is wrong syntax because you’re opening and closing PHP tags twice. The second problem is the wrong usage of single_tag_title()
.
If you want this function to return value instead of outputting it (and you need that because you want to manipulate the string), you need to set the second parameter to false. (see the second example: https://codex.wordpress.org/Function_Reference/single_tag_title )
Also it’s a good idea to check if you didn’t get an empty result.
So your code should look like this:
<?php
$tag_title = single_tag_title( '', false );
if ( ! empty( $tag_title ) ) {
echo substr( $tag_title, 0, -1 );
}
?>
Related Posts:
- Display list of most used tags in the last 30 days
- Check if current page has given tag ID
- Stop WordPress From Removing HTML Comments In Content
- How can I let my audience tag my posts?
- How do I change the output of get_the_tag_list()?
- Query all posts with specific tag
- How to query with get_posts() for posts with any tag
- Change tooltip in tag cloud
- Getting an ordered list of tags – via wp_tag_cloud or not?
- Is it possible to filter get_adjacent_post() with tags?
- How to allow user to perform search by more than one tag
- get_post_ancestors returns empty
- Combining tags from post types
- Display tags belonging to a specific post type only
- List ‘n’ number of posts from a Tag, each with a different class or ID
- Creating a Lightweight Media Tags Plugin with a Custom Taxonomy
- Displaying the most recently used tags
- Limit tag word count
- Can’t Get ‘tag’ Page To Display only Tagged Posts
- Tags as a dropdown with set tags
- Exclude a specific tag from the get_the_tags list
- Efficient Tag Management?
- Get the latest tags in a cloud? [closed]
- Order tags by the order they were typed
- How to filter posts by specific date and its tag
- Tag subscription option in wordpress. How?
- How to allow html5 tag in WordPress
- How can I show post excerpts on the tags page?
- Tags, use both union and intersection at the same time
- How can I prevent wordpress from creating tag pages?
- how can i add all my tags to tagcloud?
- Blog post : Remove comma between Tag names [closed]
- Why does the count property of get_the_tags always return 0?
- Why word can’t be displayed in wordpress?
- How to add prefix or suffix to post_tag slug?
- Get all terms if product of that term contains a specific category
- How to get popular post tags
- Remove URL from Tag
- CPT UI – elementor tags archive template not working
- Get count of custom post tags
- WP API: Get posts excluding those with a tag or category name
- How to echo tag description on loop-page.php using WPeC 3.8
- How do I add a related tags list to a wordpress tag page
- I want a query to list tags
- Remove href tag from wp_postmeta in 34,000 posts?
- Global changing of H Tags
- May I change the order of the tags?
- Display get_the_tag_list by order entered in the backend
- get posts that doesn’t contain a specific tag
- Remove commas between tags
- How to return tags containing one, two or three exact and specific words using get_tags
- how to output tags that has specific value in slug
- Need sql to remove tags from older posts
- wordpress str_replace the content with tag
- Highlight current tag using get_tags()
- show tags on “single”-template sidebar only
- Split function “the_tags” in 2 columns
- Is there any way of making post tags (or custom post type tags) pop up as suggestion as in StackExchange sites?
- How to display tags with post_content
- Exclude Specific Tag On Homepage
- Code to check how many posts a tag has?
- Change Size of P Tag on One Page Template [closed]
- How to list all tags except the current tag in tag.php
- tag is working in chrome but not in firefix..What is the problem? [closed]
- How to add keyword field in custom form programmatically?
- How to add meta tags on password-protected homepage? [closed]
- Adding Related Articles to post
- WordPress title as keywords (tags) with excluded stop words
- Separate the tag by comma [duplicate]
- Add/remove tags on frontend programmatically
- No line breaks in tags in tag cloud
- Custom text for certain tags
- get_edit_tag_link does not return anything
- get an attachment’s media tags or check if it has a media tag?
- Anyway to retrieve a feed of posts that have BOTH tags?
- Top ten tags ala Delicious
- Links from the_tag not working
- List latest post for each tag with a category
- limit number of tags shown in tag.php
- Remove H1 site-tittle tag from product page with a function SEO
- Display text if title in archive has specific word
- Tag pages with regular editor
- How to remove base tags at the wordpress
- How to select tags in the frontend
- How are special characters encoded in tag-URL?
- Open graph ‘image’ content appears empty on debugger and filled in web source
- Is there a way to change the Tag selector from text input to checkmarks?
- how to see P and BR tags in tinymce?
- WordPress tinyMCE Keep Wrapping Tags To HTML Codes When Saving
- Neverending tag problem
- Exclude Tags by Array
- Update tags to 10,000+ posts with wpdb?
- Create another TAG widget for posts
- Need to display tag group as first name, last name but sort on last name
- HTML5 Summary tag in editor
- How to list Tags using get_tags in an html table?
- How can i get tag without />?
- How to add tags to identify custom post types in archives?
- How to make attachment tag archive visible on page
- What file is responsible with tags displaying on the post?