Support

Account

Home Forums Feature Requests ACF + Yoast SEO 3.0

Solved

ACF + Yoast SEO 3.0

  • With Yoast’s SEO ( > 3.0 ) Plugin it’s now possible to validate all our ACF Fields with Javascript. I’ve wrote a small plugin which takes care about validate the ACF Fields on the fly.

    It’s public and free: https://bitbucket.org/snippets/dachcom/KKLM7/yoastseojs-acf-fields

    Watch it in action here: http://recordit.co/IsR59PtzvA

  • Thats a cool little plugin, nice work.

  • I’m sure this will be of value to anyone using that plugin.

    Does it work with both ACF4 and 5?

    Have you thought about making this into a plugin?

  • @hube2: Sorry, it will work only with ACF 5, because only ACF5 provides the Javascript-Hooks ( add_action() ) which are very important for this feature.

    Maybe i’ve misspelled it: It’s rather a extension than a plugin. So at the moment i will not create a plugin for this.

  • thank’s for the clarification on the version. I actually should have realized that it wouldn’t work on 4. But it will help others that find this thread.

  • Thanks for sharing this @solverat – was looking into adding ACF-fields. The web is still filled with the old wpseo_pre_analysis method http://support.advancedcustomfields.com/forums/topic/yoast-seo-acf/

  • Very nice @solverat !
    But, and this might sound very stupid, where to put this JavaScript.
    The heading says ‘Include this Javascript ONLY in BackEnd.’.
    Can I just put this in my ‘js’ folder of my theme?
    And where and how do I call for this JavaScript in ACF?

  • I just load it on admin_init

    function load_yoast_acf_link() {
    	wp_enqueue_script( 'acf_yoastseo', get_template_directory_uri() . '/acf_yoastseo.js', 'jquery' );
    }
    
    add_action( 'admin_init', 'load_yoast_acf_link' );
  • Hi guys

    Thanks for sharing this topic, code and ideas.

    This is very interesting, and something I can see being added to ACF quite easily.

    I’ll admit, I don’t yet understand how the WPSEO JS model works, and doesn’t look to be simple to understand but I’ll add this to my to-do and hopefuly find an elegant solution for a future version.

    For now, please use the above plugin by @solverat

    Great work guys!

  • Hi Elliot,

    Thanks for joining in. Glad to hear it has your attention.

  • Thx @solverat Good solution for now πŸ™‚

  • It would be good to filter which fields get included then. Some may not always be used on page.

    Another thought is, sometimes I use an ACF-field for the h1-tag. I don’t know how/if there is a way to let Yoast know about that, though.

  • I have no idea what I’m doing wrong but I can’t get this to work. I’ve added it in the back end fine (I can see it in the source and its all linked up fine) but yoast isn’t seeing any of the ACF’s. Anyone else not got this working. Super keen to get a work around as I have the bulk of my pages content in ACF’s

  • Hi

    Please can anyone let me know the code function to call this in genesis.

    Ive added the JS to the folder and tried the code from above

    function load_yoast_acf_link() {
    wp_enqueue_script( ‘acf_yoastseo’, get_template_directory_uri() . ‘/acf_yoastseo.js’, ‘jquery’ );
    }

    add_action( ‘admin_init’, ‘load_yoast_acf_link’ );

    But its not working – yoast is not recognising any ACF fields

    Thanks

  • This reply has been marked as private.
  • @semplify: if you enqueue the script like this, it should work:

    wp_enqueue_script('acf_yoast', get_template_directory_uri() . '/assets/js/acf_yoast.js', array('yoast-seo'), false, true);

  • I haven’t been able to get this to work either. I added the script and enqueue script as above but ACF isn’t recognising the fields. Am I missing something?

    This would be so helpful if I could get it to work!

  • ACF is struggling with text-area. Some of text-areas i have don’t have full editing capabilities (wysiwig) and are simply text areas. These areas are detected by the plugin, but the content pulled was null:

    In the code there are multiple cases for different type of content, i.e.:

    case 'wysiwyg' :
        value = $el.find('textarea').val();
        break;
     case 'textarea' :
        value = $el.find('textarea').val();
        break;

    When i’ve added case textarea – it fixed the issue.

    case 'textarea' :
        value = $el.find('textarea').val();
        break;

    I’m on WP 4.4
    Yoast SEO 3.0.7
    ACF Pro 5.3.3.1

  • I used the script provided by @solverat, because it was advised. There were some issues with the script that I have tried to address, see the bitbucket site.

    There is one issue that is not easily solved with the documented ACF hooks:

    The script currently processes image fields by fetching the thumbnail HTML. However, the alt attribute of this image tag is not updated (and why should it?), and the alt text is stored via a separate AJAX request. Is there any way to fetch the image details via AJAX?

  • Hi Solverat,

    Congratulations on a very smooth job. Have you considered submitting this plugin as a WordPress plugin? That would allow us to automatically update the plugin whenever it is updated (and to give a nice rating πŸ™‚

    https://codex.wordpress.org/Plugin_Submission_and_Promotion

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

The topic ‘ACF + Yoast SEO 3.0’ is closed to new replies.