Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67441

How to fix character encoding in Wordpress title for comma, apostrophe or quotes?

$
0
0

I'm using a custom function to fetch RSS feeds based on the Wordpress title.

Works great but if title contains a comma, apostrophe or quote it breaks the feed because it is submitting the html encoding as part of the RSS feed search URL.

The goal is to have the RSS feed search URL contain the exact text that's in the Wordpress title, without any html character encoding. I tried html_entity_decode(get_the_title()) and it gets rid of apostrophe and quotes, but it does not work for commas. I'm guessing need to do a str_replace to get rid of commas but not sure the best way to go about it and also incorporate with the html_entity_decode function.

Here's the custom function I'm using (as a little custom plugin) for now. Thanks for your help!

add_shortcode( 'custom_rss', 'execute_custom_rss_shortcode' );
function execute_custom_rss_shortcode() {
  return do_shortcode('[wp_rss_retriever url="https://news.google.com/rss/search?q=' . get_the_title() . '&hl=en-US&gl=US&ceid=US%3Aen" items="10"]');

Viewing all articles
Browse latest Browse all 67441

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>