@oliveirataquari
Solution is pretty simple:
Make your function start_el in menu-in-post.php to looks like:
function start_el(&$output, $item, $depth = 0, $args = null, $id = 0)
{
// You need $wp
global $wp;
// Create each option.
$item_output = '';
// Add spacing to the title based on the depth.
$item->title = str_repeat(' - ', $depth * 1) . $item->title;
// Get the link.
if (!empty($args->append_to_url)) {
$attributes = !empty($item->url) ? ' value="' . esc_attr($item->url) .
$args->append_to_url .'"' : '';
} else {
$attributes = !empty($item->url) ? ' value="' . esc_attr($item->url) .
'"' : '';
}
// Here you're setting selected attribute on option
$attributes.=' '.(home_url( $wp->request )==substr($item->url,0,-1) ? 'selected="selected"' : '');
// Add the HTML.
$item_output .= '<option'. $attributes .'>';
$item_output .= apply_filters('the_title_attribute', $item->title);
// Add the new item to the output string.
$output .= $item_output;
}
-
This reply was modified 3 years, 8 months ago by kojotkk.