Jean is an Internet and Multimedia specialist with a keen interest in music, technology, business, sports and psychology.
Jean Galea
Internet Consultant in Malta
Jean Galea: entrepreneur and internet specialist. Holding an M.Sc. in Multimedia & Internet Computing from Loughborough University, Jean specialises in web design and development, email marketing systems and general internet consultancy.
How to break down a WordPress post title into two parts
I am using a wordpress post to display testimonials, using the post content as the testimonial itself and its title for displaying the person giving the testimonial, and his company. In order to separate the name of the person from his company name and thus style them differently, I used the following code:
< ?php
$title = $post->post_title;
$namecompany = explode("-", $title);
echo ($namecompany[0].' - '); ?>
< ?php echo ($namecompany[1]); ?>
As you can see, we are using the $post->post_title variable which contains the title of the post, and then using the PHP function explode to break up the title into two parts based on the dash separator.
Related posts:
- PHP Notes – POST Vs. GET
- Using the Post Thumbnail feature in WordPress
- Extracting Images from a WordPress Post
- The Ultimate WordPress Thumbnail Hack
- Plugin to disable WordPress Post/Page options
Leave a Reply
Thank you for reading this blog. Please check back for new posts.

