dreamci Posted June 18, 2010 Share Posted June 18, 2010 Hello, my wordpress generates this code <li class="page_item page-item-27"> but page_item page-item-27 always changes, how can i remove class="page_item page-item-27" part from the code, thanks for looking Quote Link to comment https://forums.phpfreaks.com/topic/205155-replace-help/ Share on other sites More sharing options...
Adam Posted June 18, 2010 Share Posted June 18, 2010 What do you mean, how can you remove it? Quote Link to comment https://forums.phpfreaks.com/topic/205155-replace-help/#findComment-1073905 Share on other sites More sharing options...
dreamci Posted June 18, 2010 Author Share Posted June 18, 2010 i tried preg_replace("class=\"page_item page-item-[0-100]","",$string); but it doesnt work, any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/205155-replace-help/#findComment-1073919 Share on other sites More sharing options...
dreamci Posted June 18, 2010 Author Share Posted June 18, 2010 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/205155-replace-help/#findComment-1074093 Share on other sites More sharing options...
techiefreak05 Posted June 18, 2010 Share Posted June 18, 2010 Where is the number coming from? We need more code to see the whole picture Quote Link to comment https://forums.phpfreaks.com/topic/205155-replace-help/#findComment-1074095 Share on other sites More sharing options...
Alex Posted June 18, 2010 Share Posted June 18, 2010 Something like this? $string = preg_replace('~\s*class="page_item page-item-[0-9]+"\s*~', '', $string); Quote Link to comment https://forums.phpfreaks.com/topic/205155-replace-help/#findComment-1074097 Share on other sites More sharing options...
dreamci Posted June 18, 2010 Author Share Posted June 18, 2010 Something like this? $string = preg_replace('~\s*class="page_item page-item-[0-9]+"\s*~', '', $string); it didnt work, any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/205155-replace-help/#findComment-1074121 Share on other sites More sharing options...
phant0m Posted June 18, 2010 Share Posted June 18, 2010 Couldn't you edit the template and remove the class thingy altogether? Quote Link to comment https://forums.phpfreaks.com/topic/205155-replace-help/#findComment-1074126 Share on other sites More sharing options...
Alex Posted June 18, 2010 Share Posted June 18, 2010 Post your exact code and what you're exactly trying to match, I tested the code I posted with what you provided and it worked fine. Quote Link to comment https://forums.phpfreaks.com/topic/205155-replace-help/#findComment-1074127 Share on other sites More sharing options...
dreamci Posted June 18, 2010 Author Share Posted June 18, 2010 i am using this code; $pages=wp_list_pages('exclude=Home,90&echo=0&title_li='); $pages = preg_replace('~\s*class="page_item page-item-[0-9]+"\s*~', '', $pages); echo $pages; it returns me <li class="page_item page-item-27"><a href="http://www.domain.tv/news/" title="News">News</a></li> <li class="page_item page-item-30"><a href="http://www.domain.tv/resources/" title="Resources">Resources</a></li> <li class="page_item page-item-31"><a href="http://www.domain.tv/submit/" title="Submit">Submit</a></li> i am trying to clear all classes from here Quote Link to comment https://forums.phpfreaks.com/topic/205155-replace-help/#findComment-1074130 Share on other sites More sharing options...
Alex Posted June 18, 2010 Share Posted June 18, 2010 This works for me: $pages =<<<TEXT <li class="page_item page-item-27"><a href="http://www.domain.tv/news/" title="News">News</a></li> <li class="page_item page-item-30"><a href="http://www.domain.tv/resources/" title="Resources">Resources</a></li> <li class="page_item page-item-31"><a href="http://www.domain.tv/submit/" title="Submit">Submit</a></li> TEXT; $pages = preg_replace('~\s*class="page_item page-item-[0-9]+"\s*~', '', $pages); echo $pages; Output: <li><a href="http://www.domain.tv/news/" title="News">News</a></li> <li><a href="http://www.domain.tv/resources/" title="Resources">Resources</a></li> <li><a href="http://www.domain.tv/submit/" title="Submit">Submit</a></li> Quote Link to comment https://forums.phpfreaks.com/topic/205155-replace-help/#findComment-1074134 Share on other sites More sharing options...
dreamci Posted June 18, 2010 Author Share Posted June 18, 2010 weird , it doesnt work for me, i copied your code and tested it , it doesnt remove classes Quote Link to comment https://forums.phpfreaks.com/topic/205155-replace-help/#findComment-1074136 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.