Remove HTML tags from post title...

Hello,

I need a nudge in the right direction. I have a line of php that outputs a title from a newsfeed. The news uses html tags in the title and when they’re brought over they break because the plugin I’m using doesn’t support html tags.

Example: Tech battle with 'patent trolls'

That’s fine. I don’t need the html tags in the title. What I would like is to completely strip out the html tags leaving only the post title. Here’s the line:

<?php echo $feed->itemTitle; ?>

I’ve tried this:

<?php echo strip_tags($feed->itemTitle); ?>

But it’s having no affect on the title - i.e., the title still renders as above.

Any ideas on what I’m doing wrong?

Yep, the h3 tags are not part of the the variable.

I imagine this $feed->itemTitle; simply holds the string ‘homepage’ or something along those lines.
Not

homepage

as you are anticipating.

Make sense?
Red :wink:

They are encoded strings.

Try something like:

echo strip_tags(html_entity_decode($feed->itemTitle));

I did think of this and was midway through typing this very answer then i re-read the question and by the looks of it the h3 tags are not inside the variable:

I can see that some tags are encoded but the one supplied is an apostrophe, not a h3 tag which only reinforced my decision that the tags in question are not in the variable.

Maybe the OP could try both and let us know if either was successful.
Red :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service