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
- The Ultimate Wordpress Thumbnail Hack
- How to Auto Update the Year in your Website Footer
- Filter for excluding certain categories in Wordpress
- Best Wordpress Calendar Plugin
Leave a Reply
Thank you for reading this blog. Please check back for new posts.

