The code below was assembled of different pieces I’ve found around and it was not tested. Consider it as an idea only.
<?php
add_filter( 'the_title', 'my_capitalize_title', 10, 2 );
function my_capitalize_title( $title, $id ) {
// get separate words
$words = preg_split( '/[^\w]*([\s]+[^\w]*|$)/', $title, NULL, PREG_SPLIT_NO_EMPTY );
$stop_words = array(
'the', //
'a',
'and',
'of',
);
$title_case="";
foreach( $words as $word ) {
// concatenate stop word intact
if ( in_array( $word, $stop_words ) ) {
$title_case .= $word;
}
// or concatenate capitalized word
$title_case .= ucfirst( $word );
}
return $title_case;
}
You have to polish the idea: you don’t want “The Simpsons” to become “the Simpsons”.
Related Posts:
- How to change the case of all post titles to “Title Case”
- Apply the_title() filter in post & page title, but not in menu title
- Remove post title input from edit page
- Set Post Title to Read-only and Disable Permalink Slug Editor in Gutenberg
- Disallow Same Post Title
- Get title of post without using the_title();
- Verify if tag is used on posts
- Dynamically update post title in admin page
- How to show posts rank based on custom field value
- Displaying Page Title on index.php
- How to intercept Post Title on Post-Save
- Testing for post title in ‘if/else’ statement returns no content
- get_post_field – Title without paragraph
- Add Category name to Post Title (h1)
- How to add a custom field after wp post
- Sorting posts alphabetical that have single digits
- How Can i Get 5 Recent Post Title With Corresponding Link?
- I want to show category in the post title , how can I do
- How to prevent WordPress from updating the modified time?
- How to display following posts titles in separate div’s on a separate webpage
- Blog Posts not showing title
- Lose “Blog Archive” from page title
- How to Orderby Comments by post title?
- WordPress not opening posts with only numbers if permalink is post_name
- sql select for post_title and a term name
- WordPress is replacing double minus signs in Post Title, how to disable it?
- How do I change the core post search algorithm? Where is it found/constructed?
- Is there a way to specify an extra class for a post or page with no title?
- Add title for previous and next posts to Yoko Theme
- Images inside post title
- Loop doesn’t show title of second post and posts thereafter
- How to show show the Second page title in the page
- How to get links to the last N posts in a specific category?
- Create a list of posts with topic headdings
- Blog post not showing title
- How can I remove the first two words and shorten get_the_title()
- How do I include the category next to the title of a post?
- How to style archive post titles… but only those posts who have comments?
- Replace image name on upload to the new post name on front-end form
- Edit the post title from the frontend
- Why in my query is display two title?
- Image behind the post’s title
- Change Post Title For Specific Category
- How to remove “» (title of post or page)”?
- Auto update post title and slug when post status is changed
- Get featured image on hover of post title [closed]
- Microformats in a single post – layout conflict
- How do I display the post_title with get_permalink?
- Post titles and thumbnails as links to custom post types?
- If post exists, make it a comment in existing post with same name?
- Changing The Default Header POST Title and Description text by category in wordpress
- Change modified date to current date when title updated automatically
- How to select a category automatically based on a word in WordPress post title?
- how to show current date on post title which should be auto update in every day
- Adding Text after Post Title based on Category using IF Condition – But not for menu items
- How to merge the content of posts that have the same title?
- Post title not displaying as recorded in the wp_posts table
- Create/Set Category as Title of Post
- long-title posts do not want published
- Please I want to prefix my WP posts title according to each category
- Add id attribute to h1 element of wordpress post
- Post title spoiler how?
- Odd hyphen added at end of blog post
- My posts page is missing the page title
- Hiding title of selected post without plugins
- 2 Domains, Same Content, Different Titles?
- Post Category link is same with Page link
- Hide title in Merlin Theme on posts and pages only
- How can I choose and change a post title at random from an array when it is published?
- Post title to show all characters after having it limited for preview
- Add Image Before Posts Entry Title
- prevent same wordpress post title
- Get post title by Alphabet
- Get post title of faulty link on 404 error page
- How to get all post titles starting with numbers and symbols?
- Is it possible to have different header style blog titles in different categories?
- Custom Post Title as search term
- Is there a way to separate wordpress titles from their posts?
- display only the title of the post into a certain category
- How do I show the post title if an advanced custom field hasn’t been used?
- Deleting first four characters from all Post Titles
- Single post pagination
- How remove “recent comments” title without modifying code? [closed]
- clicking on page title
- Title displaying multiple times
- Custom Post-Rename Function Does Not Function in WordPress 6.x
- How to change Post title background size?
- How to link Post Title to uploaded file?
- Front-End Post Submission
- Display all search results
- Add default content to post (for specific category)
- blog page showing only first post
- Including text at the end of every post
- How to set post expiration date and time and move the page to archive after expiration [closed]
- .current-menu-item class on custom post type children pages – again?
- How to remove text and retain in caption image using the_content function
- display jumps to the bottom, dosnt start at the top?
- “Blog pages show at most” in setting not working
- What permissions does a role need for the user to be assigned as the author of a post?
- How to automatically convert a form with HTML link into post