Word capitalising for listing Title

This topic contains 5 replies, has 3 voices, and was last updated by  Naveen Giri 4 years, 7 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #534049

    Eugene UK
    Free User
    Post count: 39

    Hi!

    I have this snippet that works well for capitalising the listing title in case the user didn’t bother to use capital letters:

    add_filter('wp_insert_post_data','_capitalise_title_func',10);
    function _capitalise_title_func($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;
    }

    Could you please be kind enough to help me adjusting it, so the post_title in the plugin’s custom data table is also capitalised? I think it requires the return of $postarr instead of $data, but I am not certain.

    Thanks!
    Eugene

    #534094

    Kor
    Moderator
    Post count: 16516

    Hi Eugene,

    Thanks for your reply. Have you tried using custom CSS ? Like this one https://www.w3schools.com/cssref/pr_text_text-transform.asp text-transform – capitalize

    #534159

    Naveen Giri
    Moderator
    Post count: 1559

    Hi Eugene,

    Please try it.

    
    add_filter('geodir_save_post_data','_capitalise_meta_title_func',10);
    function _capitalise_meta_title_func($data){
    	$data['post_title'] = ucwords( $data['post_title'] );
    	return $data;
    }
    
    #534173

    Eugene UK
    Free User
    Post count: 39

    Dear Naveen,

    Thank you ever so much! It’s simple, elegant and working 🙂

    Eugene

    #534174

    Eugene UK
    Free User
    Post count: 39
    This reply has been marked as private.
    #534181

    Naveen Giri
    Moderator
    Post count: 1559

    Awesome, glad it helped.

Viewing 6 posts - 1 through 6 (of 6 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