Post navigation

code snippets

WordPress wp_dropdown_pages() function – replace indented spaces for child pages

As the WordPress function uses spaces to indent child pages, the indents disappear on an iPhone select list making the select menu difficult to navigate, especially if you have a lot of pages.

To get around that – add a filter in your functions.php file to replace the three non-breaking spaces “&nspb;” with two dashes and a space…

function insert_dashes_into_dropdown($output)
{
	$text = str_replace('  ', '--', $output);
	return $text;
}
add_filter('wp_dropdown_pages', 'insert_dashes_into_dropdown');

The select menu on the iPhone will now look more like this…

About David Goodman

One thought on “WordPress wp_dropdown_pages() function – replace indented spaces for child pages

  • That’s hilarious, I was just going to write this myself to fix the view on the iPhone. Thanks for sharing the code. Very useful.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please enable javascript to post a comment !