Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Meta is saving correctly but cannot figure out how to get saved meta chosen as selected
- // Contributors Circle Meta Box Layout
- function contributors_circle_meta_box( $object, $box ) {
- // $get_categories pulls all regular post categories
- $get_categories = get_terms('category');
- // $my_query pulls all current employee names (employees are in as a custom post employees)
- $my_query = new WP_Query('post_type=employees');
- $published_contributors = new WP_Query( array ( 'orderby' => 'date', 'order' => 'DESC', 'post_type' => 'contributors_circle' ) );
- $selected='';
- // this foreach displays each category name with a dropbox with a choice of all current //employees, it is displaying correctly, except that it does not have the correct employee
- // name selected when the edit page loads. I have printed the_meta() on the page, the correct // data is showing but cant pull it up as selected.
- foreach ($get_categories as $term){ ?>
- <div id = "outerwrap">
- <div id = "innerwrap">
- <p style="font-weight:bold;">
- <?php echo $term->name;?>
- </p>
- </div>
- <select name="contributor-<?php echo $term->slug?>">
- <option id="no-contributions" value="No Contributions Received">No Contributions Received</option>
- <?php
- // This while loop loads the names of all the employees which are a custom //post type, the title of the custom post type is the name of the employees
- while($my_query->have_posts()) : $my_query->the_post();
- $contributor_meta = get_post_meta($current_post->ID, 'contributor-' . $term->slug, TRUE);
- // If the name of the employee that is being pulled (title of the custom post
- // type employees) equals the $contributor_meta (also the employees name this
- // is saving correctly but currently the if statement is passing as TRUE for
- // all employees passing through
- if (the_title() == $contributor_meta){
- $selected=' selected="selected"';
- }
- else {$selected='';}
- ?>
- <option <?php echo $selected?> id="contributor-<?php echo $term->slug?>" value="<?php the_title() ?>"><?php the_title(); ?></option>
- </div>
- <?php
- endwhile;
- ?>
- </select>
- <?php
- }
- wp_reset_Query();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement