Using pipe (' | ') to separate nav links [update]
-
Hi, i was checking for a suitable function for listing the pages with pipes in footer. I have found a useful post here
The last guy used the method for string replacing. Some how his function is not suitable for me because it was still echoing the li. So i modified the code placed it in a function. The topic was closed. So, i post it here. You might found this useful.
function page_list_with_pipe(){ // wp_page_list with separator element $args = array( 'title_li' => '', 'exclude' => '120,121', 'child_of' => 0, 'parent' => 0, 'exclude_tree' => '', 'hierarchical' => 1, 'echo' => 0 ); $pgl=wp_list_pages( $args ); $sep=' | '; // separator $rep1='<li'; $rep1by='<span'; // replacing the <li with <span $rep2='</li>'; $rep2by=$sep.'</span>'; // replacing </li> with </span> $pgl=str_replace($rep1,$rep1by,$pgl); $pgl=str_replace($rep2,$rep2by,$pgl); if($sep!='') : $pgl=strrev($pgl); $sep=strrev($sep); // this is needed for removing the last separator $pgl=explode($sep,$pgl,2); // this is needed for removing the last separator $pgl=implode('',$pgl); $pgl=strrev($pgl); // this is needed or removing the last separator endif; echo $pgl; // echo pagelist } ?>In my personal opinion this kinds of function should be include in wordpress (or may be there is and i don’t know!) anyone can post upgraded code. Thanks!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Using pipe (' | ') to separate nav links [update]’ is closed to new replies.