• Resolved ps3hero

    (@ps3hero)


    i have this code to get a custom field with some text (name, surname, adress) + an email adress (i mean, it’s all mixed in one WYSIWYG field):

    <?php if(get_field("info")): ?>
    <?php the_field("info"); ?>
    <?php endif; ?>

    any idea how to edit the code to work with “email adress encoder” plugin?

    https://wordpress.org/plugins/email-address-encoder/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter ps3hero

    (@ps3hero)

    got it working with the filter method. in functions.php put:
    add_filter('acf/load_value', 'eae_encode_emails');
    works for me.

    Thread Starter ps3hero

    (@ps3hero)

    hmm, doens’t seem to work on all custom fields, only some … 🙁

    Plugin Author Till Krüss

    (@tillkruess)

    What does the code look like on an example where the acf/load_value filter doesn’t work?

    http://www.advancedcustomfields.com/resources/filters/acfload_value/

    Thread Starter ps3hero

    (@ps3hero)

    this works:

    <?php if(get_field("adresse")): ?>
    <?php the_field("adresse"); ?>
    <?php endif; ?>

    this doesn’t work:

    <?php
    $toppage=array_reverse(get_post_ancestors($post->ID));
    if($toppage[1]){
    echo str_replace("\n","<br/>",get_post_meta($post->post_parent, 'kontaktdaten', true));
     }
    ?>

    any idea?

    Plugin Author Till Krüss

    (@tillkruess)

    Yes, you’re fetching your custom field data manually and not through the ACF function.

    Try this code:

    $toppage = array_reverse( get_post_ancestors( $post->ID ) );
    if( isset( $toppage[1] ) ) {
        echo eae_encode_emails( nl2br( get_post_meta( $post->post_parent, 'kontaktdaten', true ) ) );
    }

    Check out PHP’s nl2br() as well…

    Thread Starter ps3hero

    (@ps3hero)

    thank you so much this works! nl2br is much … shorter 😀

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘how to make it work on advanced custom field? filter? php?’ is closed to new replies.