The goal to publish a standard Category and then have a user post a GF where one of the field entries is used to append the existing Category name. Thus, "Credit Request" becomes "Credit Request: ENG 500". This could work as either an append, or with the field entry as a Category Description and the original Category name remains the same. It's good either way as long as the user is able to see what they entered previously when they publish future posts to that Category.
Tried many ways to do this but I lack the chops to pull off the final steps. Here is the logic of the process:
1 - User enters the name of a college course in the form (custom field) with a CF name "credit_request".
2 - That entry is used to append an existing category "Credit Request" to produce: "Credit Request ENG 500" which will be displayed in a primary menu.
3 - Subsequent form entries can then be submitted to this category, with the "Credit Request: ENG 500" displayed to the user as one of the category options to choose from in the form. (I haven't gotten to this stage yet. One problem at a time).
I have assembled a description walker to place this new custom field data into, but I don't know how to call the GF custom field into it. It is provided below. I assume I need to declare a variable that identifies the GF custom field ID entry, and then call it later as one of the $item_puts, but my syntax fails.
class description_walker extends Walker_Nav_Menu
{
function start_el(&$output, $item, $depth, $args)
{
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
$class_names = ' class="'. esc_attr( $class_names ) . '"';
$output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
$description = ! empty( $item->description ) ? '<span>'.esc_attr( $item->description ).'</span>' : '';
$item_output = $args->before;
$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before .apply_filters( 'the_title', $item->title, $item->ID );
$item_output .= ?????????????;
$item_output .= '</a>';
$item_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
}
I have also tried to pull the output of Category Description from the custom menu items - which worked if I manually type it in in the Custom Menu item's description box. But there is no way for the user to type in a Category Description directly in GF. Thus, I am using a custom field as a surrogate to get it to appear as an append to the category name, and forgetting about using Category Description.
Either method would be satisfactory to solve #2 of my logic list from above.
Thank you for your help. - Steve