mnybud Posted April 1, 2012 Share Posted April 1, 2012 I am trying to learn PHP and am a novice so please excuse the stupid question but I have researched and attempted to find a solution for this and cant. Hoping someone can help me. I have the following code I am using within a Wordpress template... <?php if (function_exists('simple_feed_list')) : ?> <?php $title = get_the_title(); str_replace("+", " ", $title); simple_feed_list('http://www.amazon.com/rss/tag/'. str_replace(" ", "+", $title) .'/new/ref=tag_tdp_rss_new_man?tag=search-20','limit=5&desc=yes&nofollow=yes&more=no'); ?> <?php endif; ?> I am trying to make it produce a RSS feed url from amazon that looks like this: http://www.amazon.com/rss/tag/ipod ibuds/new/ref=tag_tdp_rss_new_man?tag=search-20 note the space between ipod and buds, that is what I am trying to accomplish. Right now the space is being changed I think to a + sign which breaks the feed if the search term is more than one word. Can anyone help me fix this? I have tried removing the string replace part, etc with no luck Quote Link to comment https://forums.phpfreaks.com/topic/260140-str_replace-help/ Share on other sites More sharing options...
mnybud Posted April 1, 2012 Author Share Posted April 1, 2012 I have also tried this with no luck... anyone have any ideas? <?php if (function_exists('simple_feed_list')) : ?> <?php $title = get_the_title(); simple_feed_list('http://www.amazon.com/rss/tag/'. str_replace("", "", $title) .'/new/ref=tag_tdp_rss_new_man?tag=search-20','limit=5&desc=yes&nofollow=yes&more=no'); ?> <?php endif; ?> Quote Link to comment https://forums.phpfreaks.com/topic/260140-str_replace-help/#findComment-1333309 Share on other sites More sharing options...
Muddy_Funster Posted April 1, 2012 Share Posted April 1, 2012 <?php if (function_exists('simple_feed_list')) : ?> <?php $title = get_the_title(); $url = "http://www.amazon.com/rss/tag/$title/new/ref=tag_tdp_rss_new_man?tag=search-20"; $url = urlencode($url); simple_feed_list($url,'limit=5&desc=yes&nofollow=yes&more=no'); ?> <?php endif; ?> url's dont have spaces in them Quote Link to comment https://forums.phpfreaks.com/topic/260140-str_replace-help/#findComment-1333318 Share on other sites More sharing options...
mnybud Posted April 1, 2012 Author Share Posted April 1, 2012 thanks but that still is not working. It works if the page title is one word but not if it is more than one. and in this case the urls do include a space....example. max results http://www.amazon.com/rss/tag/ipod accessories/new/ref=tag_tdp_rss_new_man?tag=biblesforthew-20 limited results http://www.amazon.com/rss/tag/ipodaccessories/new/ref=tag_tdp_rss_new_man?tag=biblesforthew-20 Quote Link to comment https://forums.phpfreaks.com/topic/260140-str_replace-help/#findComment-1333323 Share on other sites More sharing options...
mnybud Posted April 1, 2012 Author Share Posted April 1, 2012 anyone else help. the suggested code above actually doesnt even work on a single term Quote Link to comment https://forums.phpfreaks.com/topic/260140-str_replace-help/#findComment-1333341 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.