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 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? 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? 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? 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 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); 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? 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? 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. 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 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> 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 Link to comment https://forums.phpfreaks.com/topic/205155-replace-help/#findComment-1074136 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.