There are actually two problems:
-
The
&
is encoded as&
, so you have to usehtml_entity_decode()
first. -
Multi-byte characters need more than one byte, and
strlen()
will fail with them. Don’t use strlen().
So use something like this:
$title = html_entity_decode( get_the_title(), ENT_XML1, 'UTF-8' );
$length = mb_strlen( $title, 'utf-8' );
Related Posts:
- Filter the blog title displayed in the header
- Blank on static home page?
- “Maximum function nesting level of ‘100’ reached” after adding a new filter
- String replace WordPress Site Title
- Customized title tag for each page in pagination?
- Browser title script ignoring is_page /else conditional [closed]
- Blank space at beginning of tag?
- Filter get_the_title to remove certain characters?
- get_page_by_title with an apostrophe in variable
- Locating Global Variables
- Set post title based on first h2 element in the content section
- An extra ‘ is displayed in the title
- Part of title duplicating but not sure how to remove from code – help?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Remove the first 5 characters of the_title and orderby that
- Change title only in dynamic page
- Display custom post type title as text if post thumbnail is not available
- Change page title from page using php via php executed from page/post itself
- Reduce size of responsive title
- Run str_replace on title and save the output to a custom field
- Echo title attribute php
- change title page on search result
- woocommerce related product title length
- Split site title and apply different classes
- Insert content into head tag with function
- How do I choose not to display the title header on a specific page?
- Set document title through shortcode plugin
- how to replace h1 entry title with h2 in category pages only
- Posts title instead of Pages and Category titles – PHP WordPress
- Time Stamp In A WordPress Post Title That Does Not Keep Refreshing
- How can I get the custom post title?
- Site title not showing. Please help me
- How to display custom seo title before the loop?
- Put a span class in the shortened product title
- Allowing HTML elements in title widgets spacing problem
- “Page Array” displaying in title bar on Front Page
- Replace Underscore (_) on Space ( )
- my site show this symbol (::) between site title and tagline
- Display tab title as ‘blog tagline | blog title’
- Custom field in title
- Hide page title
- Getting a specific “title for a section” only on Startpage?
- How to return number of found rows from SELECT query
- WP API V2 returning Invalid User ID
- Why does $_SESSION only work when I am logged in?
- removing tags from wp_list_pages() using PHP
- How to Append to the_excerpt() Function
- How to check for WordPress timezone type?
- Why do filters/actions require an argument count?
- Callback URL in WordPress
- woocommerce and is_user_logged_in() if not redirect to homepage
- Adding a querystring to an image URL when clicking ‘insert into post’?
- Wrong links in WordPress?
- Add HTML Attributes To Anchor Tags In `wp_list_categories()` Function
- Is there any difference between get_the_title() and single_post_title()?
- Deregistering a script in WordPress seems impossible
- custom shortcode will not display the wrapped content
- Common abstract class for plugins
- Where do posts get the sidebar from?
- putting Mailto: and Tel: into footer.php code wordpress
- understanding if statement [closed]
- Logged in user ID as post ID
- How to use $query->set with post__in?
- PHP file won’t work in wordpress folder, but works in another virtual host
- I want to add custom add to cart link [closed]
- How to add condition in wordpress loop? [closed]
- If no image, bigger text
- Custom plugin settings link doesn’t append current class to menu item when visited? Why?
- WordPress admin-ajax.php 400 bad request
- Custom Background by Page IDs
- What is the proper way to include a PHP framework into my theme?
- Help with page nav?
- Can a plugin redirect product page based on IF condition?
- How to use mysql LIKE with wpdb?
- Get all posts as an array ID => Name
- How to store multiple custom meta box
- cURL error 6 on news area, and also won’t auto update
- How to manually trigger a redirect to another page without changing the url address?
- How to use title attributes in sidebar widget?
- How to get my [shortcode] rendered on the home page, other pages are fine
- Wp favorites posts by specific category? [closed]
- Fatal error login WordPress [duplicate]
- Pagination contents not changing in Front page WordPress
- How to select post ID for given parent name with nested prepared queries?
- Can I disable auto increment of WordPress Posts Database to utilize previously deleted records?
- How to apply ‘add two more posts’ to media content?
- How to disable sub menu items from being created?
- Access to “My Site” is missing from the admin bar
- Unable to insert current username into custom table through html form
- add ‘publish metabox’ to Gravity forms edit page/form area
- How do I modify the Previous and Next Page posts on blog pages to include “previous” and “next” before the links?
- How can i iterate through this shortcode array?
- How do I prevent a folder from reappearing in my home directory?
- Styling admin page rows in order of importance (checkboxes)
- On selecting shortcode generate selected shortcode table inside page editor worrdpress
- How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
- PHP Puzzle: Unique Styles with PHP loop
- Find owner of coupon
- WordPress wp_remote_request() – How to do async await in wordpress php?
- How Create Automatically Image jpg.webp from image .jpg without delete or change original images upload