Advertisements
Connect with us

Tips & Tricks

Remove spaces when echoing the_title

Ever wanted to print or echo the WordPress title attribute without spaces?

Advertisements

This little trick can be useful for calling custom functions and printing the title with out spaces for W3C compatibility. I used this trick in a new theme called Galleria, which will be out for public download in the coming days.

Using this comes in handy for a delicious text link:

<?php $title = get_the_title(); ?>
<a href="http://del.icio.us/post?url=<?php echo $title; ?>&amp;<?php echo str_replace(" ", "%20", $title); ?>">
Bookmark This (<?php echo $title; ?>)</a>

What I am doing is calling $title = get_the_title(); and using str_replace(" ", "%20", $title); to replace empty spaces with a %20, which is used in URL encoding empty spaces.

Alternatively you can use a dash or underscore.

Thanks to Jason Boyle for his adaption.

Advertisements

Random Search Terms

Title

Top Articles

powered by WassUp

Recent Posts: Fully Net Worth . com

Harold Lederman Net Worth: How Rich Was Boxing Legend Actually?

Harold Lederman Net Worth: How Rich Was Boxing Legend Actually?

Harold Lederman was a boxing judge and analyst. He was in boxing for around 5 decades. Harold Lederman net worth before his death is estimated to be $3 million. Lederman was born on January 26, 1940, in The Bronx, New York. He went to Columbia University and after graduation earned a license from New York’s […]

Pua Magasiva Net Worth: How Rich was Pua Magasiva Actually?

Pua Magasiva Net Worth: How Rich was Pua Magasiva Actually?

Pua Magasiva was a New Zealand actor best known for his role as Shane Clarke, the Red Ranger from Power Rangers Ninja Storm. Pua Magasiva net worth before his death is estimated to be $600,000. Magasiva was born on August 10, 1980, in Apia, Samoa but was raised in Wellington, New Zealand since he was […]

MindofRez Net Worth: 5 Interesting Facts You Should Know

MindofRez Net Worth: 5 Interesting Facts You Should Know

Bryan Carti is a Youtuber who is well known for his channel called “MindofRez” which he started on June 8, 2016. Here are some interesting facts about MindofRez: 1. MindofRez has an estimated net worth of $2 million As of 2019, MindofRez net worth is estimated to be around $2 million. MindofRez has been able […]