Adding description after title
-
I have been trying to modify the plugin code to add support for menu item descriptions below the titles.
I borrowed part fo the code from this tutorial and replaced this bit of code in menu-image.php:
$item_output = $args->before; $attributes .= " class='{$attributes_classes}'"; $item_output .= '<a' . $attributes . '>'; $link = $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
with:
$prepend = '<strong>'; $append = '</strong>'; $description = ! empty( $item->description ) ? '<span>'.esc_attr( $item->description ).'</span>' : ''; if($depth != 0) { $description = $append = $prepend = ""; } $item_output = $args->before; $attributes .= " class='{$attributes_classes}'"; $item_output .= '<a' . $attributes . '>'; $item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID ).$append; $item_output .= $description.$args->link_after;
This works in a way, because the description is now being outputted after the title as expected. The only problem is that this seems to break the image positioning function that follows it. Even if I choose to display the title after the image, the output always shows it before the image.
How do I get the title positioning to work properly and still keep the description output?
BTW the plugin still works flawlessly in WP 3.9, it would be good to add menu item description support in the next release.
Thanks
- The topic ‘Adding description after title’ is closed to new replies.