Support

Account

Forum Replies Created

  • Actually, this causes a conflicting problem because I originally applied it to one custom field section, which worked, but now other different ACF WYSIWYG field sections that need line breaks are having their breaks removed. 🙁

  • Thanks elliot! That did the trick. 🙂

  • I did

    <div>Name(s): <?php the_field('name', false, false); ?></div>

    But it still outputs like this:

    <div>
    Name(s):
    <p>
    <a href="#">Name</a>
    </p>
    </div>
  • Yeah, when you click on the ACF text field, then press tab, it takes you right to the content. Or if you click on the ACF text field, then press shift+tab, it takes you to the “Edit” button above, then one more time takes you to the title field. But hitting tab while in the title always skips over the ACF and right to the content. =(

    It’s not a huge problem, but it is slightly annoying always skipping over that field (or fields) and having to click to go back. =/

  • Ok, so the below code no longer causes the conflict, but is still requiring me to do the double update which is back to where we started:

    
    // Custom URL Post Title
    
    function custom_url_post_title($data , $postarr) {
    	if ( !in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
    		$custom_field_title = get_post_meta($postarr['post_ID'], 'heading2', true);
    		if(isset($custom_field_title) && $custom_field_title != '')
    			$data['post_name'] = sanitize_title($postarr['post_title'].'-'.$custom_field_title);
        }
        return $data;
    }
    add_action ('wp_insert_post_data','custom_url_post_title', 99, 2 );
    
    // End Custom URL Post Title
    
    // Custom ACF
     
    function custom_post_title( $value, $post_id, $field  )
    {
    	// update the $post via the wp_update_post function
        
        
        
        
        return $value;
    }
     
    // acf/update_value/name={$field_name} - filter for a specific field based on it's name
    add_filter('acf/update_value/name=heading2', 'custom_post_title', 10, 3);
    
    // End Custom ACF
    
  • Hmm… When I add the code you just wrote, I get the error:

    Fatal error: Cannot redeclare custom_post_title() (previously declared in /home/movies9/public_html/msv6/wp-content/themes/Media/functions.php:1824) in /home/movies9/public_html/msv6/wp-content/themes/Media/functions.php on line 1884

    When I remove my old code (mentioned above) that seems to be causing the conflict in the functions.php file, the permalink+heading2 no longer works and I’m left with the heading2 being left out of the URL again with nothing changing no matter how many times I hit the Update post button.

  • @elliot

    Looking in the docs I found to use this:

    <?php
     
    function my_acf_update_value( $value, $post_id, $field  )
    {
        $value = "Custom value";
     
        // do something else to the $post object via the $post_id
     
        return $value;
    }
     
    // acf/update_value - filter for every field
    add_filter('acf/update_value', 'my_acf_load_field', 10, 3);
     
    // acf/update_value/type={$field_type} - filter for a specific field based on it's type
    add_filter('acf/update_value/type=select', 'my_acf_load_field', 10, 3);
     
    // acf/update_value/name={$field_name} - filter for a specific field based on it's name
    add_filter('acf/update_value/name=my_select', 'my_acf_load_field', 10, 3);
     
    // acf/update_value/key={$field_key} - filter for a specific field based on it's name
    add_filter('acf/update_value/key=field_508a263b40457', 'my_acf_load_field', 10, 3);
     
    ?>

    However, adding just that to my functions.php causes a bunch of errors when trying to publish a post:

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'heading2' not found or invalid function name in /home/movies9/public_html/msv6/wp-includes/plugin.php on line 199
    
    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'heading2' not found or invalid function name in /home/movies9/public_html/msv6/wp-includes/plugin.php on line 199
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/movies9/public_html/msv6/wp-includes/plugin.php:199) in /home/movies9/public_html/msv6/wp-admin/post.php on line 222
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/movies9/public_html/msv6/wp-includes/plugin.php:199) in /home/movies9/public_html/msv6/wp-includes/pluggable.php on line 899

    If I just want this to effect the “heading2” custom field. How would I edit it?

  • Edit: Ok @Elliot, I think I figured out what our problem is…

    We already have a custom field called “thumbnail_large” that we’ve been using for years before ACF and I just setup ACF to use the same “thumbnail_large” custom image field. This way all of our old posts could have their field’s automatically added as ACFs. I’ve seen this happen before with other custom fields and ACF text fields, and it worked.

    In this case, however, it doesn’t seem like it’s doing what we want it to do. By adding an image as the ACF “thumbnail_large” field, it also adds the image’s ID as a default custom field. Because our conditional statement is working as it should, it sees that “thumbnail_large” is true, however, because ACF is adding the value as an id (in the backend) it tries to use just the id as a src and fails.

    Is there a way to get the ACF to output the image’s value as the actual URL instead of the id in the backend editor?

  • Hey @elliot,

    I actually have tried using .acf_wysiwyg iframe too, that was my mistake that I didn’t mention it above. But what exactly would I use if I wanted to set the height to 15px? I tried:

    .acf_wysiwyg iframe {
    	min-height:0;
    	height:15px;
    }

    But it seems like WordPress won’t allow the WYSIWYG field area to be anywhere near that short. It won’t even let me click and drag the bottom right corner to make it shorter than what looks like around a height of 100px. I ended up hacking it a bit more using this to get what I wanted:

    .acf_wysiwyg iframe {
        height: 15px;
        min-height: 15px;
        overflow: hidden;
    }
    
    .acf_wysiwyg .wp-editor-container {
    height:70px;
    overflow: hidden;
    }

    Let me know if there’s a better way of doing this. Also, where exactly should I be editing this code? Right now I’m just using a custom function in my functions.php file that adds the custom css to the admin’s head.

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