Post Title capitalise first letters programatically?

This topic contains 2 replies, has 2 voices, and was last updated by  Eugene UK 5 years, 4 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #515572

    Eugene UK
    Free User
    Post count: 39

    Hi.
    If a user forgets or misses out on making the first letters in the post’s Title upper case, is there a way to capitalise them before saving to database?
    Thanks in advance.
    Eugene

    #515573

    Guust
    Moderator
    Post count: 29970

    Hi Eugene, you can use this CSS to capitalise each word in a title, for example

    .entry-title {text-transform: capitalize;}

    Thanks

    #515575

    Eugene UK
    Free User
    Post count: 39

    Thanks, Guust, for responding so promptly.
    I actually got a tip from Stiofan to implement the following snippet, which resolved the issue:

    add_filter('wp_insert_post_data','_capital_title_dangit',10);
    function _capital_title_dangit($data){
    	if(isset($data['post_type']) && function_exists('geodir_get_posttypes') && in_array($data['post_type'],geodir_get_posttypes()) && isset($data['post_title'])){
    		$data['post_title'] = ucwords( $data['post_title'] );
    	}
    	return $data;
    }

    Cheers!

Viewing 3 posts - 1 through 3 (of 3 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount