Search code examples
phpjquerywordpresspermalinks

Wordpress wp_list_pages() with permalinks


I'm using wp_dropdown_pages() in Wordpress. It's working fine, displaying a nice refined dropdown list of pages. My issue is that the value of each select holds the page ID, not it's permalink - do any of you guys know how I can replace this value?


Solution

  • Find this file: wp-includes/post-template.php

    Find this line inside function start_el():

    $output .= "\t<option class=\"level-$depth\" value=\"$page->ID\"";
    

    (It should be on line 1415). And replace it with this:

    $output .= "\t<option class=\"level-$depth\" value=\"".get_permalink($page->ID)."\"";
    

    I'm not sure if it's the proper way, but it will get the job done!