Support

Account

Forum Replies Created

  • Hi John,
    I managed to get it working. Thanks! Is there any possibility to save the title when I use bulk edit? The title is only saved when I open the custom post type and hit the save button. It is not working when I use quick edit or bulk edit.

  • Hi John, thanks for the advice. I edited my functions.php like below:

    function my_acf_save_post( $post_id ) {
        
    $post_title = get_the_title( $post_id );
    update_field('titel_acf', $post_title, $post_id);
    return $post_title;
        
    }
    
    add_action('acf/save_post', 'my_acf_save_post', 20);

    The field titel_acf still does not get updated 🙁

  • Hi John! Thanks for the advice. I editet the script like below but it still does not work:

    function update_acf_title($value,$post_id, $field){
    
    $post_title = get_the_title( $post_id );
    update_field('titel', $post_title, $post_id);
    return $post_title;
    }
    add_action('acf/update_value/name=titel','update_acf_title',11,3);

    I installed the ACF to Rest-API plugin to get all my fields via JSON but unfortunately I don’t have the page title, which is the most important thing 😉

    If you have any others ideas please let me know.

  • Hi John, thanks for the tipp! I tried to change from key to name but no difference. I also changed the name of the acf image to “bild” and adapted the code – but affects. I don’t understand why .. :/

    //Auto assign Featured image from 'post_image'
    function acf_set_featured_image( $value, $post_id, $field  ){
    
    	$value = get_field('bild', $post_id);
        
        if($value != ''){
    	    //Add the value which is the image ID to the _thumbnail_id meta data for the current post
    	    update_post_meta($post_id, '_thumbnail_id', $value);
        }
        return $value;
    }
    add_filter('acf/update_value/key=bild', 'acf_set_featured_image', 10, 3);
  • Hi John, thanks a lot! I also tried this but no featured image is shown. I check the featured image with the following code:

    <?php
    // check if the post or page has a Featured Image assigned to it.
    if ( has_post_thumbnail() ) {
        the_post_thumbnail();
    } ?>
    

    This is probably a stupid question. But I have defined $value in the functions.php with the following:

    $value = get_field('1_bild', $post_id);

    Is this correct? @John

  • Hi @jonathan , I have read this topic and tried to adapt it to my needs but it is not working. Maybe you could help me our here. I have a CPT with some images. I would like to define of of the images as my featured image. The image is called “1_bild” and I have set it as an image-array at the ACF configuration. I have used the following code but it does not work for me:

    //Auto assign Featured image from 'post_image'
    function acf_set_featured_image( $value, $post_id, $field  ){
        
        if($value != ''){
    	    //Add the value which is the image ID to the _thumbnail_id meta data for the current post
    	    update_post_meta($post_id, '_thumbnail_id', $value->ID);
        }
        return $value;
    }
    add_filter('acf/update_value/key=1_bild', 'acf_set_featured_image', 10, 3);
    

    What am I doing wrong here?

    Thanks a lot!

  • Hi James, I saw this topic and I am facing the same issue as some others here. Maybe you can help me out too, here 😉

    I have the following code:

    <?php
    
                        foreach ( $terms as $term ) {
    
                       $image = get_field('berufe-thumb', $term->taxonomy . '_' . $term->term_id );
                        echo '<pre>';
    
                        echo "Image field value:";
                        var_dump($image);
    
                        echo '</pre>';
                         
    
                ?>

    The result is: Image field value:NULL

    Could you have a look at it, please?

  • I solved it myself with the following code:

    <?php
    $text = get_field('einleitungstext');
    $text = str_replace('<p style="text-align: justify;">', '<p>', $text);
    echo $text;
    ?>
  • Thanks John! I looked into your links.
    Do I need to register a taxonomy for every “dropdown”-field I have in my ACF? In this case I need to fill out twice everything, correct? So for example I have to select “2 years” in the acf-dropdown and select “2 years” in my newly created taxonomy “duration”.

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