Support

Account

Home Forums Front-end Issues Specific Fields for specific taxonomies on Archive Page

Solving

Specific Fields for specific taxonomies on Archive Page

  • Hi there,
    I’ve been reading through Forum to see if I can find an answer to the issue I’m having. Found some similar ones but got lost in the code, (not very good at it) and each with their own issues. So here is my issue I need some ideas for please:

    I have a CPT called Listings and one of the taxonomies I created for it is ‘Land-Plot’.
    I was able to create different acf fields and show them with conditional logic at the back end.
    For example, if cpt taxonomy is ‘Land plot’ show these fields, etc.
    This is working fine at the back end, but:

    I have created an archive page where all my Listings live.
    I can show whatever acf I created through Dynamic Fields for Elementor PRO, so no problem.

    In each listing type on the archives page, I have an extra toggle section, where in there I display a set of 2-3 different extra attributes of that listing type.

    One of the specific fields I created for this section is, ‘Land Type’

    While I can select it when editing my Listing Archive Page, what happens is it shows this particular acf in all other listing types as well, regardless of their taxonomy. So when I open the toggle area, the content is the same, regardless of the listing type.

    For example, listings with a taxonomy called ‘Houses’ show the ‘land-only’ custom field in the toggle area, instead of ‘House-only’ field, and vice versa.

    Hope I’m making sense here??
    How can I have my archive page, populate the specific custom fields in their respective listing types??

    A further example for archive page in front-end:
    1) Listing type: House
    Toggle area: Bedrooms: 3
    2) Listing type: Land-Plot
    Toggle area: Land type: even

    Thank you in advance for your time and suggestions!

  • Someone…please!
    There’s got to be a solution out there somewhere..?

  • If you were using PHP and editing template files then I could help you. But you are using Dynamic Fields for Elementor PRO and you need to figure out how to show or not show fields based on the term of a post using this tool and your question should be directed to users of this tool.

  • Hi John Huebner,

    Thank you for your time to reply and your willingness to help!
    I’m not certain I understand why I should direct my questions to Dynamic Fields!?
    I understand that I’m using Dynamic fields sure, but, I’m using them to display ACF. If you’re not coding them yourself to display them at the front-end, (which is by itself a complex undertaking), then, you’ve got to use some other means/tool to display them right?
    My issue is that there aren’t ‘display conditions’ within the field’s menu, (when you create that particular field), to manage when you show that field, or not. I use display conditions on a ‘field group’ level to display them at the admin screen only.

    I have 2 Field Groups. Both, for the same CPT.
    One is for ‘house listings’ the other for ‘land listings’.
    How can I make both group fields show for the particular listing on an archive page?
    This archive page displays both listing taxonomies. Users can filter out which type they want to see, but on page load, both are visible to the user.
    So far, I found that I can only display one or the other, no matter what taxonomy is displayed at front-end.
    I was partly able to show particular ‘section’ of taxonomy by using the ‘Dynamic Conditions’ plugin.
    But I’d love to figure out how to really solve this problem.

    Thanks again for your time!

  • The reason is that ACF does not include conditions for showing fields on the front end and this requires coding, for example

    
    // get terms associated with post
    $terms = wp_get_post_terms($post->ID, 'your-taxonomy');
    // see if there are terms
    if ($terms) {
      // loop over terms
      foreach ($terms as $term) {
        // test to see if this is a term with custom field to show
        if ($term->name == 'special term') {
          // get the value of the field from the term
          $term_field = get_field('field_name', $term);
        }
      }
    }
    

    I cannot tell you how to do this is a tool designed to build output in the admin and more than likely no one that visits this forum will be able to help you with this. Most of the people that use ACF code templates using PHP. ACF is an admin tool that helps you create fields and does not include automated code for displaying the values on the front of the site.

  • I see…!
    Thank you for your patience!!
    It’s very unfortunate though that ACF has not evolved to broaden its usage for front-end displaying too!
    On the other hand, thank God we have tools such as elementor and dynamic fields to help us most of the way with this.

    I will try and implement your code in my functions.php and see if I can make it work that way. I will back-up, then back-up and back-up my installation before I proceed and see if I can work it out 🙂

    I can understand some pieces of your code, but I couldn’t come up with it myself…!

    Thank you again!!!

  • That code may not be precisely what you need, it was just a quick example.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.