How to assign a custom field to specific categorie(s) only?

Custom fields should be assignable to different categories, correct? I have not yet found the way to do that.

It seems that a client wanting to post in the directory about his hotel would want to have custom fields available that were appropriate to a hotel, and not have to wade through lists and lists of custom fields that were appropriate only to beauty salons or for legal advice.

I hope that this plugin can do it. Other directory plugins not being touted as "the best" do, but I opted for WPMU as I loved your confidence in the copy writing and the fun in the video presentation! Don't let me down!

  • PC

    Hello Dan,

    Greetings and thanks for your post and welcome to WPMU DEV.

    The directory plugin comes with CustomPress included ( https://premium.wpmudev.org/project/custompress/ ) which you can use to create any number of Custom Post types on your Site. You can create different custom fields and assign them to different custom post types. So the X custom post type will have a,b,c custom fields and so on.

    Here is the CustomPress usage guide in case you need it at any point : https://premium.wpmudev.org/project/custompress/#usage

    I hope that helps. Please feel free to ask if you have more questions on the same.

    Cheers
    PC
    Sales &Support

  • dan_locke

    Do you happen to have an example of this being specifically applied to the directory plugin? There does not seem to be any mention of the directory plugin in the documentation referenced.

    I am sure that it can be extrapolated and I am willing to give it a go but I have been muddling over it for about a half an hour and getting frustrated.

    I will sleep and wake up refreshed and relaxed and with a better measure of confidence... but what a nice surprise to wake and find something even more specific to the task at hand waiting for me!

  • Jack Kitterhing

    Hi there @dan_locke

    I hope you are well today.

    With categories, you want to create categories for directory or you want to apply custom fields to the directory post type, or you want to apply custom taxonomies to the directory post type?

    In wp-admin > CustomPress > custom fields > add new > on that page, where you choose your post type on the right hand side, the post type you want is "directory_listing", then once that is choosen, fill in the rest of the information, i.e if it's a text box, single line text, checkbox etc, the name and the values (if checkbox) and save, this is then applied to the directory_listing post type.

    If you just wanted to add categories, you could go to listings > categories > add new.

    Please advise, what you'd like to achieve, I'm here to help :slight_smile:

    Thank you!

    Kind Regards
    Jack.

  • dan_locke

    Hello there, Jack! Yes. I'm well today. Thank you for asking! Are you well today as well? :slight_smile:

    Thank you for your kind offer of assistance. I'm going to take you up on this. You and PC have probably already answered my questions. I guess the terminology has confused me a little bit, so perhaps you can help me even a little bit further. I am building a directory with many different categories, such as restaurants, hotels, legal advice, translators… All the different things that I can think of that might assist people to have access to while living in a foreign country.

    So, I am wanting my clients to be able to select easily between different categories of services, and, once they have chosen the category that they want their directory submission to be placed under, to have only the custom fields that would be appropriate to that category.

    For example:

    Category: hotels. Possible custom fields available to be assigned to this: room service, dry cleaning, laundry, spa, gym.

    Category: restaurants. Possible custom fields available to be assigned to this: drop-down menu regarding price ranges, wine list? Desserts? Cabaret entertainment? Multiple-choice entry for types of food available.

    Category: attorneys at law. Possible custom fields available to be assigned to this: checkboxes for family law, immigration law, contract law, etc.

    Right now I have various categories already listed and created in my plug-in. I haven't yet figured out how to assign particular custom fields solely to one or another of these categories.

    I believe I will figure it out if I have to buy myself, but I know with your assistance I will get it done much more quickly. So, I look forward to your response!

  • dan_locke

    Your hopes are fulfilled! I am well!

    Yes, you are correct: I want these to be conditional. When I think about it, it seems to be about the most typical thing one would want out of a directory, unless there was only to be one niche in each directory.

    Yes, Jack, if you could figure that out... nice!.

    If you anticipate this not being quick to resolve, would you let me know to expect that. If that is the case, I will look for other solutions.

  • Arnold

    Did you look at the Shorcodes page in CustomPress? This requires changing code in templates and some knowledge of PHP.

    You would want to change the /directory/ui-front/single-listing.php. You'll find a

    [custom_fields_block]

    in there and you'll need to add filters to it to suit the categories you need as per the Shortcodes page. There's more on the Usage page for CustomPress

    https://premium.wpmudev.org/project/custompress/#usage

  • dan_locke

    Hello there!

    I am back!

    I'd like to see is the user interface or ease of use for this plugin has been upgraded since we first started this thread. Although I know that I can do all these changes in the template; I have so many different things that I am going to want to classify and categories and assign different conditional fields.

    What I am asking for is typical and available right out of the box in every other directory plugin I have researched. They are all premium though and are asking for $99 typically and have not wanted to spend that.

    Surprised this basic functionality has not been available here as an easier to use option.

    If there hasn't been an upgrade I will stop working with this plugin. Please advise.

    Dan

  • dan_locke

    I want to tell you exactly what I want to do, and be as clear as possible and then you tell me if it's likely that will be able to do it together, okay?

    I am setting up the site to be of use to visiting people from the US and Europe to Ecuador. I want to set up a directory that gives bilingual resources residential resources and tourist type resources.

    I like to set it up so that a bilingual college student, looking for some extra money, might come to the site and register and give a brief description of himself, uploading a photo, and then choosing from custom fields like "primary language?", "Secondary language?", "Do you have your own transportation?", "What cities and areas are you familiar with and feel that you could give a nice tour of?" (With a drop-down list perhaps of different cities and places.)

    A real estate agent or developer would log into the site and have a place to upload the photos of his residences and also supplies some information, but his custom fields would be entirely different for his category. How many bedrooms? How many bathrooms? Listing price? All the various things we see in a typical real estate listing.

    And someone operating some sort of tourist attraction would also have a place to upload his photos and give his description, but he would have an entirely different set of custom fields to check off or fill out. These might be things like, kid safe?, Wheelchair access?, Café available?, Etc.

    There would be more categories in this, eventually. But, I think these are the ones I have chosen for now.

    I don't know PHP. I do know how to follow specific instructions. Given enough time, I can sometimes figure out a general solution like, "read the usage page to find out how" and use it to solve my problem. But, I found that often takes hours to figure out, whereas it might only taken half an hour for someone to write out a specific answer to my specific question.

    I know that I haven't bought the "superduper" membership, but, I think I've been here for over a year now or thereabouts, so I have plugged in some cash here. Do you think it's likely that I'm going to get more specific detailed answers to my questions here, or is it more likely that I'm going to get the sort of answers that I've been getting from Arnold?

    I'm certain that there are lots of people who have even a moderate understanding of PHP that can take the sort of answers that Arnold gives or has been giving and get things done with them. I'm just not up to that level.

    That's no criticism of Arnold. It's just in asking for clarification about support here. Do you think we can work together to get this solved if I need more detailed answers? Should I put this project aside and close out my membership until I gathered enough money together to pay for a developer to help me out?

    Please let me know your thoughts on this.

  • dan_locke

    I want to ask some questions about what Arnold said earlier, I will post my questions after his instructions.

    Did you look at the Shorcodes page in CustomPress? This requires changing code in templates and some knowledge of PHP.

    You would want to change the /directory/ui-front/single-listing.php. You'll find a

    [custom_fields_block]

    in there and you'll need to add filters to it to suit the categories you need as per the Shortcodes page. There's more on the Usage page for CustomPress

    https://premium.wpmudev.org/project/custompress/#usage

    I looked at the shortcodes page in CustomPress.

    I want to be sure you understand that I want to have different custom fields sets that are exclusive to different categories. It seems that further instructions are necessary to accomplish this. Am I misunderstanding you or is there more instructions needed to accomplish what I want?

  • dan_locke

    Jack,

    this is a thread that started 7 months ago. You have replied to it a few times earlier as well.

    Not quite sure what I mean when I say, "Please read the thread"? I don't know if I can say that more simply, I'll try though. Here we go:

    1. Go to the beginning of the thread.
    2. Read each item, including yours.
    3. You'll see that "Use Custom Press" has probably been suggested 6-7 times. Being told that again, and only that, well, that's not too helpful.
    4. You will see Arnold gave some instructions but acknowledged that you need to know .php to do it.

    You guys are all great and smart, but it's looking to me like, unless it is something really really simple, none of you really want to help on anything complicated to a person who is not a code person.

    I'm not saying that's wrong. I'm also not saying that's right. I'm just putting it out there to talk about.

    What I am asking for is step by step, how to do it. That's what I am asking for, Something a lot more specific than "Use Custom Press!" and more detailed than Arnold.

    But, please do read this thread in it's entirety. It won't take long.

    If you look through it you'll see that I am asking for something rather specific.

  • Jack Kitterhing

    Hi there @dan_locke,

    as explained further up the thread and when I responded with

    It's not currently possible to have conditional custom fields based on category, they would need to be separate post types, so this wouldn't work, without creating custom post types

    The specific thing you need to achieve isn't possible out of the box with most plugins, the closest you'd get would be a conditional form using Gravity forms and then using the posting functionality.

    As per my suggestion if you was going to go the other route and create custom post types then it would be CustomPress, then you can have fields per custom post type.

    If you'd like the CustomPress modified to have conditional fields, you could try posting a job on the WPMU DEV job board here https://premium.wpmudev.org/wordpress-development/

    Thanks.

    Kind Regards
    Jack.

  • Arnold

    I'll take another crack at defining this. I think part of the problem is what you call categories should really be attached to the user. You want the user type to determine what fields show. A student looking for part time work, A real estate agent posting properties. etc. You need to know that Before you start the listing input because you can't change the fields around once the Listing page is on the screen.

    WordPress has a mechanism for this in it's Roles and Capabilities.

    https://codex.wordpress.org/Roles_and_Capabilities

    When a user signs up on your site they would have to indicate what Role they are looking for and then that could be used to control which listing fields are shown. You may have problems with a person who fits more than one role. Because a person can only belong to one role.

    That's were custom capabilities can help. They can be added as sets to an individual user. This capability would give this set of fields. Add this capability and you'd see both sets of fields. How you would display the final listing would be problematic. Something like add a capability to the user and that adds a category to the listing that displays those fields to everyone else on the listing view.

    But again it's custom programming. Figuring out how to get people to properly self manage their own capabilities might get hairy.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.