Support

Account

Forum Replies Created

  • That is strange.
    I am using advanced scripts for my code snippets. As soon as I activate the script above, the error is there (when I save a post). When I deactivate the script, the error is gone.

  • Hello John!

    Thanks very much for your help!

    I have tried to set up a function with your changes as follows:

    <?php
    
    //Make special artist field autosave for sorting
    function write_artist_name_to_hidden( $post_id ) {
    
    //Get the value of the relationhip field, unformatted, from the project post being saved.
    $kuenstlerinnen_id = get_field ('project_to_kunstlerin', $post_id, false);
    //The above value could be an array
    if (is_array('kuenstlerinnen_id')) {
        $kuenstlerinnen_id = kuenstlerinnen_id[0];
      }
    
      //get the last name field from the other post
    
      $artist_nachname = get_field('artist_nachname', $kuenstlerinnen_id);
    //update the field on the project with this value
    
    update_field('project_kunstlerin_nach_name_sort', $artist_nachname, $post_id);
    
      }
      add_action('acf/save_post', 'write_artist_name_to_hidden', 11);

    Sadly I am doing something wrong here, as get several warnings when I try to update a post:
    Warning: Illegal offset type in isset or empty in /Users/sebastianalbert/Local Sites/fotohof-calling/app/public/wp-content/plugins/advanced-custom-fields-pro/includes/local-meta.php on line 195

    Warning: Illegal offset type in isset or empty in /Users/sebastianalbert/Local Sites/fotohof-calling/app/public/wp-content/plugins/acf-extended/includes/core/meta.php on line 168

    Warning: Illegal offset type in isset or empty in /Users//Local Sites/fotohof-calling/app/public/wp-content/plugins/advanced-custom-fields-pro/includes/local-meta.php on line 195

    Warning: Illegal offset type in isset or empty in /Users//Local Sites/fotohof-calling/app/public/wp-content/plugins/acf-extended/includes/core/meta.php on line 168

    Warning: Cannot modify header information – headers already sent by (output started at /Users//Local Sites/fotohof-calling/app/public/wp-content/plugins/advanced-custom-fields-pro/includes/local-meta.php:195) in /Users//Local Sites/fotohof-calling/app/public/wp-includes/pluggable.php on line 1340

    Warning: Cannot modify header information – headers already sent by (output started at /Users//Local Sites/fotohof-calling/app/public/wp-content/plugins/advanced-custom-fields-pro/includes/local-meta.php:195) in /Users//Local Sites/fotohof-calling/app/public/wp-includes/pluggable.php on line 1343

    Do you have any idea what I am doing wrong here? I am pretty new to the php stuff.
    Thanks again for your help!

  • I am trying to display the whole tree of the taxonomy within the select field.
    So that “parent => child => 2child” is shown, when selecting a term.
    Any idea how to accomplish this?

    Thanks very much!

  • I also would really love to see OSM to be included in the AFC core. Sad that this hasn’t been done until 2021…
    Any news when we finally get OSM aim the core of AFC?

  • Hello! Thanks again! Sometimes the easy approach actually works.

    <?php 
            // vars
            $value = get_sub_field('what3words');
            $str2 = ltrim($value, '/');
    ?>
    
    <a href="https://w3w.co/<?php echo $str2; ?>">/// <?php echo $str2; ?></a>
  • Hopefully other map providers could be implemented in the ACF (google) map field. Especially since Google has changed their MAP-API for the worse.

  • I have finally found a working solution:

    <?php
    $file = get_field('dokumente_datei');
    $url = $file['url'];
    $image_id = $file['id'];
    $image_url = wp_get_attachment_image($image_id,'medium');
    if( $file ): 
    
    ?>
        <a href="<?php echo $file['url']; ?>">
           <?php echo ($image_url); ?></a>
    
    <?php endif; ?>
    
  • I have got this somehow to work:

    <?php
    $text = get_field('dokumente_datei');
    $stripped_text = str_replace(".pdf","-pdf.jpg","$text");
    ?>
    
    <img src=<?php echo $stripped_text; ?>" width="100%">

    But it returns the full-size image and I need a smaller one for the post loop. As the smaller ones are named differently (pixel size added to the image names), it does not work either as I try to get it to work….

  • Thanks again for your help. I am pretty new with all this.

    I have now tried around several attempts, but I still get an error:
    Parse error: syntax error, unexpected ‘false’ (T_STRING), expecting ‘)’ in (…)/wp-content/plugins/oxygen/component-framework/components/classes/code-block.class.php(115) : eval()’d code on line 2

    <?php if( get_field('dokumente_datei') ): 
    $file_id = intval(get_field('dokumente_datei', false false));
    $image = get_attachment_image_src($file_id, 'thumbnail');
    
    ?>
    <img src="<?php echo esc_attr($image); ?>" />
    
    <?php endif; ?>

    Your help is highly appreciated!

  • Thanks very much for your help!!!

    I somehow get an 500 error, when I try to run your script above.
    Think I am missing something here.

  • Trying to achieve the same.
    I have a post type artists => artist lastname & artist first name field
    and Post Type exhibitions.

    There’s a bidirectional relationship field, which connects exhibitions to artists.

    I want to create a Slug/post-name which is …/[first 3 letters of the 1st artist’s last name]-[exhibition name].

    //Generiert bzw. ersetzt Title&Slug der Ausstellungen automatisch von ACF field Ausstellungstitel. Slug von 1.Künstler
    function ausstellungs_title_updater( $post_id ) {
    
    $my_post = array();
    $my_post['ID'] = $post_id;
    $my_post['post_name'] = $post_name;
    
    $ausstellungstitel       = get_field('_ausstellungen_titel');
    $kuenstlerabk1			= get_field ('_ausstellungen_to_kuenstlerinnen_bez');
    
    if ( get_post_type() == 'ausstellungen' ) {
      $my_post['post_title'] = get_field('_ausstellungen_titel');
     $my_post['post_name'] = sanitize_title($kuenstlerabk1 . $title );
    
    }
    
    // Update the post into the database
    wp_update_post( $my_post );
    
    }
    // run after ACF saves the $_POST['fields'] data
    add_action('acf/save_post', 'ausstellungs_title_updater', 20);

    I have used this above example to firstly only insert the exhibition title “ausstellungen_title”, which worked perfectly.

    Adding:

    $kuenstlerabk1			= get_field ('_ausstellungen_to_kuenstlerinnen_bez');
    

    gives me now only array as slug name.
    I have to somehow get the “_ausstellungen_to_kuenstlerinnen_bez”, which is the relationship field to output the slug of the first artist attached.

    Any ideas? THANK You!

  • I have got it to work with the following code:

    `

    //Custom Title&Slug Künstler von ACF fields
    function kuenstlerinnen_title_updater( $post_id ) {

    $my_post = array();
    $my_post[‘ID’] = $post_id;
    $my_post[‘post_name’] = $post_name;

    $kvorname = get_field(‘_kuenstlerinnen_vorname’);
    $knachname = get_field(‘_kuenstlerinnen_ nachname’);
    $vname = $kvorname .’ ‘. $knachname;

    if ( get_post_type() == ‘kuenstlerinnen’ ) {
    $my_post[‘post_title’] = $vname;
    $my_post[‘post_name’] = sanitize_title( $title );

    }

    // Update the post into the database
    wp_update_post( $my_post );

    }
    // run after ACF saves the $_POST[‘fields’] data
    add_action(‘acf/save_post’, ‘kuenstlerinnen_title_updater’, 20);

  • Hello,
    I have tried the other recommendations but sadly failed to achieve the following.

    I have the custom post type: “kuenstler” and the custom fields “vorname-kuenstler” and “nachname-kuenstler”.
    I now try to achieve the auto-creation of the post title and slug from these two custom fields.
    Title: “”vorname-kuenstler”[space]”nachname-kuenstler””
    Slug: “vorname-kuenstler”-“nachname-kuenstler”

    Could anybody give me a helping hand here?
    That would be so great!
    Thank you!!!

  • Hello!

    I am trying to autogenerate the title and slug out of two custom fields within a custom post type.
    The custom post type is: kuenstler
    Custom field one: vorname-kuenstler
    Custom field two: nachname-kuenstler

    Title should be “vorname-kuenstler [space]nachname-kuenstler” and slug should be “vorname-kuenstler-nachname-kuenstler”

    I have tried to follow the instruction within this thread, but I somehow cannot get it to work. I am using the latest release of ACF.

    Has somebody a working solution, which she/he could share. That would be really great!!!

  • Hello,

    I am trying to autogenerate the title and slug out of two custom fields within a custom post type.
    The custom post type is: kuenstler
    Custom field one: vorname-kuenstler
    Custom field two: nachname-kuenstler

    Title should be “vorname-kuenstler [space]nachname-kuenstler” and slug should be “vorname-kuenstler-nachname-kuenstler”

    I have tried to follow the instruction within this thread, but I somehow cannot get it to work. I am using the latest release of ACF.

    Has somebody a working solution, which she/he could share. That would be really great!!!

  • Hello,

    I am trying to autogenerate the title and slug out of two custom fields within a custom post type.
    The custom post type is: kuenstler
    Custom field one: vorname-kuenstler
    Custom field two: nachname-kuenstler

    Title should be “vorname-kuenstler [space]nachname-kuenstler” and slug should be “vorname-kuenstler-nachname-kuenstler”

    I have tried to follow the instruction within this thread, but I somehow cannot get it to work. I am using the latest release of ACF.

    Has somebody a working solution, which she/he could share. That would be really great!!!

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