• Hi, I am hoping to get a little bit of insight I have built a form for property submission. But when a user edits the property listing this button that works with taxonomy, it shows no as default even if selected.

    Heres what happens the submit listing and edit listing are two separate pages on front end. when a listing is submitted the data all gets stored ok. But if the user wants to edit the listing the term options don’t show correctly.

    So if when i submitted this property i select eg. Studio Flat so it shows yes. When i saved it goes in Taxonomy like it should. But when user goes to edit the listing and wishes to use a different term or remove from term so when No is selected remove for term.

    Hope someone can help, code is below thank you

    Listing Page:

    
    <div class="col span_4 first">
    	  <label><?php esc_html_e('Studio Flat', 'contempo'); ?></label>
    	        <select id="ct_studio_flat_type" name="ct_studio_flat_type">
    		    <option value="">No</option>
                        <option value="studio-flat">Yes</option>
    		</select>
                                </div>
    

    Edit Listing Page:

    
    <div class="col span_4 first">
       <label><?php esc_html_e('Studio Flat', 'contempo'); ?></label>
     <?php 
         $taxonomy_name = 'ct_property_type';
         $name = strip_tags( get_the_term_list( $current_post, 'ct_property_type', '', ', ', '' ) );
                  ?>
        <select id="ct_studio_flat_type" name="ct_studio_flat_type">
             <option value="">No</option>
             <option value="studio-flat" <?php if($name == 'Studio Flat') { echo 'selected="selected" '; } ?>>Yes</option>
                                </select>
                            </div>
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Try if ($name == 'studio-flat') to see if the selected attribute should be output.

    If that still fails, var_dump the value for $name to see what you are really working with.

    You might consider using selected() to determine which option is selected. It’s slightly more concise than using if() logic.

    Thread Starter Directweb

    (@directweb)

    i have if ($name == 'studio-flat') on the option. sorry im new to all this

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Taxonomy button’ is closed to new replies.