Support

Account

Forum Replies Created

  • Is there a way to add the zipcode to the long address?

    For example, the ACF fields shows below address:
    233 South Wacker Drive, Chicago, IL, USA

    I would like the zipcode included in the ACF field like below:
    233 S Wacker Dr, Chicago, IL 60606

    Having an option to drop the “, USA” would be great too.

  • I am assigning an Agents taxonomy to Homes CPT. The Agents taxonomy has custom fields for the agents picture, name, email and phone.

    Agents

    I am limited to the themes abilities to return and show items in the grid. Right now it only allows me to show items of a taxonomy. Ideally I would create a CPT Agents and CPT Homes. Then somehow relate the two and show them in the grid.

    Its a cool idea though right? I mean if I can attach the Agents taxonomy to the Home CPT with custom fields for the taxonomy for agent picture, name, email and phone its an easy solution.

    Unfortunately I don’t have coding capabilities and was hoping you would be able to come up with a solution. (i.e. the shortcode)

  • So how would I go about adding agents to Homes CPT? I thought create Taxonomy called agents and add terms which are the agents names like Jane Doe and John Doe. I attached custom fields to the taxonomy and it all looks good. I just can’t return the agents email, phone, name associated with the Home.

  • Where would I find the id for the taxonomy?

  • I have a custom taxonomy called Agents with taxonomy slug agents. I created a custom field group called Agents. The fieldnames for the fields in the group are agent_name, agent_phone, agent_email and agent_picture.

    I tried the above code like so:
    [acf field="agent_name" post_id="agents"]

    This did not return any values. How can I return custom fields attached to the agents taxonomy?

  • Hi John:

    Thank you for your response. Unfortunately I am not a PHP coder. Any chance you could put together this code?

  • Hi John,
    Thank you for the example link. Would I use Display list of posts (without setup_postdata) below?

    I am not sure what exactly is setup_postdata?

    <?php
    $featured_posts = get_field('featured_posts');
    if( $featured_posts ): ?>
        <ul>
        <?php foreach( $featured_posts as $featured_post ): 
            $permalink = get_permalink( $featured_post->ID );
            $title = get_the_title( $featured_post->ID );
            $custom_field = get_field( 'field_name', $featured_post->ID );
            ?>
            <li>
                <a href="<?php echo esc_url( $permalink ); ?>"><?php echo esc_html( $title ); ?></a>
                <span>A custom field from this post: <?php echo esc_html( $custom_field ); ?></span>
            </li>
        <?php endforeach; ?>
        </ul>
    <?php endif; ?>

    Since my Custom field is related_posts would I just change the below?

    $custom_field = get_field( 'field_name', $featured_post->ID );

    Change to…

    $custom_field = get_field( 'related_posts', $featured_post->ID );

    How can I add this all as a shortcode? I use code snippets plugin so I can create a snippet to add the whole. How can I put text before ” Related Posts:” What if there are no related posts will it return nothing?

  • Example html…

    <div class ="related-posts">
    <span class ="text-before">Related Posts:</span>
    <span class ="post"><a href="link to post">Related Post 1</a></span>
    <span class ="post"><a href="link to post">Related Post 2</a></span>
    <span class ="post"><a href="link to post">Related Post 3</a></span>
    </div>

    Example Output…

    Related Posts: Related Post 1, Related Post 2, Related Post 3

  • John, if not incorporating all options into acf standard shortcode

    [acf field="field_name" post_id="options" hide_empty="1" html_tag="div" class="my-class"]

    Then create another shortcode acf_html for adding the html

    [acf_html field="field_name" post_id="options" hide_empty="1" html_tag="div" class="my-class"]

    Would output:

    <div class="my-class">Field Value</div>

  • Rather than remembering to use another shortcode just add options to acf standard shortcode. If the option hide_empty doesn’t exist then nothing. That’s simple.

    [acf field="field_name" post_id="options" hide_empty="1"]

    This seems simple and I would venture to say many of your users already want this.

    My code had a typo because I was not used to the new shortcode

    [acf_if_value=”gv_address_2″ post_id=”options”]

    Should have been

    [acf_if_value field="gv_address_2" post_id="options"]

    I probably would not have screwed this up if it were…

    [acf field="field_name" post_id="options" hide_empty="1"]

    Regrading wrapper html and class, if the options in the shortcode don’t exist, then nothing.

    You already add separate wrapper class to style the backend admin site. When I first used ACF I thought that was what It was going to do, output to the page. Instead it was admin backend styling.

    John, I heard your a wizard, could you provide hide_empty=”1″ code?

    – Please 🙂

  • You could even add these options to Edit Field Group for each field.

    Html Tag
    Class
    Hide empty

    Values in these fields would be added to the ACF shortcode automatically. If blank, then you could add on the fly with custom shortcode.

  • You could even add these options to Edit Field Group for each field.

    Html Tag
    Class
    Hide empty

    Values in these fields would be added to the ACF shortcode automatically. If blank, then you could add on the fly with custom shortcode.

  • Two other options that would be awesome is to add html wrapper and class

    [acf field="field_name" post_id="options" hide_empty="1" html_tag="div" class="my-class"]

    This would output

    <div class="my-class">Field Value</div>

    If no value then output nothing.

    If class exists but not html tag then default to <span>

    This would be really awesome as options to the ACF standard shortcode.

  • My apologies had a typo.

    It would be awesome if you could use the original shortcode and add hide_empty =”1″.
    For example…

    [acf field="field_name" post_id=”options” hide_empty="1"]

    If hide_empty=”1″ then Hide shortcode

    This would be awesome as a standard option in ACF.

  • Still looking to have this addressed…

    I am using an ACF Option page and the above code doesn’t work. See below example…

    [acf_if_value=”gv_address_2″ post_id=”options”]

    How can I get the shortcode to work for option pages?

  • I am using an ACF Option page and the above code doesn’t work. See below example…

    [acf_if_value=”gv_address_2″ post_id=”options”]

    How can I get the shortcode to work for option pages?

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