Title: Applying different coding to extra fields.
Last modified: August 21, 2016

---

# Applying different coding to extra fields.

 *  Resolved [jiipsijack](https://wordpress.org/support/users/jiipsijack/)
 * (@jiipsijack)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/applying-different-coding-to-extra-fields/)
 * I have the extra fields module and awpcp 3.0.1 installed on my wordpress site,
   I’ve added two extra fields into my listings, one for physical address, into 
   which I’ve added a section of code to convert that field into a google maps link
   like so
    $html .= ”; } else if (count($value) > 0) { $value = awpcp_extra_fields_render_field_single_value(
   $field, $value[0]); $html .= sprintf( ‘<span class=”awpcp-extra-field-value”>**
   <address>**%s**</address>**</span>’, $value ); this also uses the convert address
   to google maps link plugin. Now I’ve added a second extra field called keywords,
   I was hoping to change the field name and value to the same color as the background
   so they aren’t on my listings looking messy but will still be recognized by the
   search form. My problem is that awpcp extra fields php file doesn’t differentiate
   between one field and another, so the **address** coding is affecting my keywords
   field and if I were to hide my keywords field I would also be hiding the address
   field. Is there any way of differentiating between different fields? for example
   some type of Query against row number etc?
 * Thanks in advance.
 * [http://wordpress.org/plugins/another-wordpress-classifieds-plugin/](http://wordpress.org/plugins/another-wordpress-classifieds-plugin/)

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Author [AWP Classifieds Team](https://wordpress.org/support/users/awpcp/)
 * (@awpcp)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/applying-different-coding-to-extra-fields/#post-4239335)
 * HI jiipsijack,
 * My developer is out on vacation for a bit so I’ll have to defer this to him when
   he returns.
 *  Thread Starter [jiipsijack](https://wordpress.org/support/users/jiipsijack/)
 * (@jiipsijack)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/applying-different-coding-to-extra-fields/#post-4239379)
 * Thanks for such a prompt reply, I look forward to hearing from him.
 *  Thread Starter [jiipsijack](https://wordpress.org/support/users/jiipsijack/)
 * (@jiipsijack)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/applying-different-coding-to-extra-fields/#post-4239504)
 * Hi there, Sorry to inundate but I see that your developer is back as other support
   queries have been resolved, was just wondering whether any ground has been made
   on this? Really need to get it sorted and I can’t figure it out by myself unfortunately,
   Thanks Again.
 *  Plugin Author [AWP Classifieds Team](https://wordpress.org/support/users/awpcp/)
 * (@awpcp)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/applying-different-coding-to-extra-fields/#post-4239505)
 * Got an answer for you here:
 * > Is there any way of differentiating between different fields? for example some
   > type of Query against row number etc?
 * Unfortunately we don’t have a way to control the output of individual fields 
   of the same type (I believe he is using two textfields). However, since he is
   already modifying the plugin’s code, he can use $field->field_name to check which
   field is being processed and apply the google maps modifications to one field
   and the keyword modifications to the other.
 *  Thread Starter [jiipsijack](https://wordpress.org/support/users/jiipsijack/)
 * (@jiipsijack)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/applying-different-coding-to-extra-fields/#post-4239506)
 * Hi there, thanks again for your reply, while I appreciate your confidence in 
   my coding abilities, unfortunately I’m not certain how to use $field->field_name
   to differentiate the fields. I see this line 30 times in awpcp_extra_fields_module.
   php. If you could tell me how to use it to see which field is being processed
   I’m sure I could figure the rest out with that as a starting point. And you are
   correct, it is two text fields.
 * Thanks in advance.
 *  Plugin Author [AWP Classifieds Team](https://wordpress.org/support/users/awpcp/)
 * (@awpcp)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/applying-different-coding-to-extra-fields/#post-4239508)
 * Hi jiipsijack,
 * If the code aspect seems a bit daunting, we would recommend that you hire a developer
   on oDesk to help with this kind of customization. There are a number of PHP/WordPress
   guys on there at reasonable prices: [http://odesk.com](http://odesk.com)
 *  Thread Starter [jiipsijack](https://wordpress.org/support/users/jiipsijack/)
 * (@jiipsijack)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/applying-different-coding-to-extra-fields/#post-4239510)
 * It doesn’t seem daunting, all I really need is a starting point so if you wouldn’t
   mind explaining how to use the $field->field_name to differentiate, I’m sure 
   I can figure the rest out myself. Thanks once again for your time.
 *  Plugin Author [AWP Classifieds Team](https://wordpress.org/support/users/awpcp/)
 * (@awpcp)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/applying-different-coding-to-extra-fields/#post-4239511)
 * The field name is the name of the field defined in your AWPCP Extra Fields admin.
   So you’d have to use some kind of conditional in the code to customize the behavior
   or output per field. Something like this:
 *     ```
       if ($field->field_name == "my_field") {
       //Do map-specific for just my_field
       }
       else {
       //Regular output for other fields
       }
       ```
   
 *  Thread Starter [jiipsijack](https://wordpress.org/support/users/jiipsijack/)
 * (@jiipsijack)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/applying-different-coding-to-extra-fields/#post-4239512)
 * Fantastic! Thank you so much for your help, The support for this plugin really
   is great. I’ll give this a whirl and let you know how it works out.
 *  Thread Starter [jiipsijack](https://wordpress.org/support/users/jiipsijack/)
 * (@jiipsijack)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/applying-different-coding-to-extra-fields/#post-4239516)
 * It’s worked! I’ve differentiated between fields now and my address field is showing
   up as a link while my keywords field is showing up hidden in listings, just like
   I wanted
 * For anyone else trying something similar the code I used looks like:
 *  `else if (count($value) > 0 && $field->field_name == “address”) {
    $value = 
   awpcp_extra_fields_render_field_single_value($field, $value[0]); $html .= sprintf(‘
   <span class=”awpcp-extra-field-value”><address>%s</address></span>’, $value );}
   else if (count($value) > 0 && $field->field_name == “keywords”) { $value = awpcp_extra_fields_render_field_single_value(
   $field, $value[0]); $html .= sprintf( ‘<span class=”awpcp-extra-field-value”>
   <font color=”white”>%s</font></span>’,`
 * However I didn’t realise that the search form doesn’t recognise the content of
   extra fields unless I have a search section specifically for that. Is there any
   way that I can change the search form so it will read from “ad title” “ad details”
   and my extra field? If you like I can start a new Forum question as this is sort
   of a different question now.
 *  Plugin Author [AWP Classifieds Team](https://wordpress.org/support/users/awpcp/)
 * (@awpcp)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/applying-different-coding-to-extra-fields/#post-4239519)
 * Yes, please start a new thread for this. And when you do, please post a screenshot
   of what you are seeing on your search screen.

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Applying different coding to extra fields.’ is closed to new replies.

 * ![](https://ps.w.org/another-wordpress-classifieds-plugin/assets/icon-256x256.
   png?rev=2944356)
 * [AWP Classifieds](https://wordpress.org/plugins/another-wordpress-classifieds-plugin/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/another-wordpress-classifieds-plugin/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/another-wordpress-classifieds-plugin/)
 * [Active Topics](https://wordpress.org/support/plugin/another-wordpress-classifieds-plugin/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/another-wordpress-classifieds-plugin/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/another-wordpress-classifieds-plugin/reviews/)

## Tags

 * [awpcp](https://wordpress.org/support/topic-tag/awpcp/)
 * [extra fields](https://wordpress.org/support/topic-tag/extra-fields/)

 * 11 replies
 * 2 participants
 * Last reply from: [AWP Classifieds Team](https://wordpress.org/support/users/awpcp/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/applying-different-coding-to-extra-fields/#post-4239519)
 * Status: resolved