PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Use custom field entry as menu item description

  1. 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

    Posted 11 years ago on Monday January 28, 2013 | Permalink
  2. I'll check with the development team on this one. I'm not sure how to answer your question at this point, but we'll get an answer for you.

    Posted 11 years ago on Tuesday January 29, 2013 | Permalink
  3. I am having a hard time understanding what exactly you are trying to accomplish, I get some of it, but for the most part, I am up in the air. Could you try explaining this again (maybe with a couple screenshots?). I think I will be able to point you in the right direction if I can fully understand what you are trying to do.

    Posted 11 years ago on Tuesday January 29, 2013 | Permalink
  4. Students are creating an e-portfolio through the process of submitting forms. Submitted forms are automatically published as posts in various categories named Credit Request 1, Credit Request 2, etc. This work pertains to a "case" students are building to get college credit for a particular course by submitting documentation that fulfills the requirements of the course. Some students apply for credit for two or three course. Thus, each submission has to be published to either a new credit request or to an existing one that they had started previously.

    Each Credit Request is initially represented in the blog's navigation using its default Credit Request name.

    The above process asks whether it is possible for the following:
    1 - Draw the course name from the submitted form and use it as an append to an existing Credit Request category name. Thus, "Credit Request 1" becomes "Credit Request 1 - ENG500". This could be done using the walker_description code from above so that the category name is literally appended in the menu display. I do not know, however, how to code the hooks to do this. Tried many things - failed.
    2 - An acceptable alternative would be to have the course name placed as a menu item description. The menu item description is normally taken from the category description, but it is possible for this to be overridden in the menu builder. Perhaps there is a way to automate this process?
    3 - Once a student has established a credit request category, such as Credit Request 1 - ENG 500, is it possible to display this to the user as a choice for a subsequent form submission? The present form design sets an initial condition: "Is this for a new credit request or an existing one?" If it is new, then process #1 (above takes place). If it is for an existing credit request, is it possible to display existing category choices with the appended name in the next field with checkboxes next to the choices?

    There are no screen grabs to offer here, so this is the best I can do. thx - Steve

    Posted 11 years ago on Wednesday January 30, 2013 | Permalink
  5. Ok Steve, I am still not 100% sure, but lets give it a try. Lets start with item 1.
    You have two fields right? A post category field (for credit request category) and another drop down (or maybe a text field) for the course name. If I understand correctly, you want the value of your course field to be appended to the value of your category field. This new value will take effect both in the entry screen as well as in the category associated with the post. The post will no longer be associated with the original category (i.e. Credit Request 1). It will instead be associated with Credit Request 1 - Course Name.
    Did I get that right?

    Posted 11 years ago on Thursday January 31, 2013 | Permalink
  6. Thank you, but no - that's not what I was referring to. I think this project is dead, but many things were learned along the way. Thank you for your attention to this. GF support is consistently terrific.

    Posted 11 years ago on Friday February 1, 2013 | Permalink
  7. Thanks for the update. I'll let Alex know.

    Posted 11 years ago on Monday February 4, 2013 | Permalink

This topic has been resolved and has been closed to new replies.