Support

Account

Home Forums Backend Issues (wp-admin) Populate Field using Post's Permalink

Solved

Populate Field using Post's Permalink

  • I’m using an add to calendar widget from dynamic.ooo and for the event’s location, I need to pull in the post url/permalink. But that field does not exist in dynamic’s data function. But I can pull in any ACF field, including a URL field.

    So I thought of creating an ACF that would be automatically generated/populated using the post’s permalink.

    I searched through different ideas but couldn’t find anything. Is this possible?

  • https://www.advancedcustomfields.com/resources/acf-save_post/

    
    add_filter('acf/save_post', 'post_permalink_to_field');
    function post_permalink_to_field($post_id) {
      $permalink = get_permalink($post_id);
      update_field('acf_permalink_field', $permalink, $post_id);
    }
    
  • Perfect! That worked exactly as needed.

    https://www.screencast.com/t/BwK6RAvb48
    https://www.screencast.com/t/T7sU2jf7

    Thank you very much!

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.