I have several posts which have similar format of titles. The title format follows like this: "ABC University - Economics" "XYZ University - Social Sciences" "KLM BBB College - Business Administration" so on...
How can I trim the post title until "-". The text after "-" I dont need. I just want get "ABC University" or "XYZ University" or "KLM BBB College".
I cannot do it with wp_trim_words() function as number of words are not same for every post title.
Can anyone help?
EDIT: this code trims post title by 3 words: echo wp_trim_words( get_the_title(), 3, '...'); I want trim post title until hyphen (-)