• I am trying to modify a theme file I have to replaces spaces with ? like so….

    $menu = wp_list_pages('title_li=&sort_column=menu_order&echo=0 '); // Params for the page list in header.php
    
    $menu = str_replace(array("\r", "\n", "\t"), '', $menu);
    
    echo str_replace(' ', 'nbsp;', $menu);

    however not having much luck

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter primefalcon

    (@primefalcon)

    what I need is for the output to be like…
    <a href=https://whatever.com>like&nbsp;this</a>

    instead the output is currently like this
    <a href=https://whatever.com>like this</a>

    You are missing the ampersand symbol from &nbsp; in the bottom line of your code.

    the extra space after echo=0 ...order&echo=0 '); is for some reason stopping this parameter from getting applied – what you see is the direct output from ‘wp_list_pages()’

    try with ...order&echo=0');

    the str_replace will then actually work on all spaces in the html string – including the useful ones in the html tags – and therefore breaking the whole output ??

    it will probably need someone with a good knowledge of ‘preg_replace’ …

    The easiest way might be to rename the Pages themselves?

    Thread Starter primefalcon

    (@primefalcon)

    @duckboy
    I had the ampersand in the original code, but when I edited this post to fix a spelling mistake the whole nbsp thing got replaced as a space here and when I edited the post a 3rd time to put it back I forgot the ampersand.

    @alchymyth
    Thank you very much, I was starting to think I would have to alter the core wordpress files themselves (which means I’d probably have to do it after every update), I’ll go and have a look at what you posted :-).

    @chip Bennett
    Not really feasible, this is on my wifes wordpress blog and she doesn’t know any of this “web stuff”

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘str_replace on wp_list_pages’ is closed to new replies.