Conditionally loading JavaScript based on the Advanced Custom Fields in the post

ACF has finegrained filters for fields when they get loaded. add_action( ‘wp_enqueue_scripts’, ‘register_my_scripts’, 5 ); function register_my_scripts() { wp_register_script( ‘my-script’, ‘path-to/my-script.js’, array(), ‘version’, true ); } add_filter(‘acf/load_field/name=my_field_name’, ‘load_field_my_field_name’); function load_field_my_field_name( $field ) { wp_enqueue_script( ‘my-script’ ); return $field; } Normally all scripts should be enqueued in wp_enqueue_scripts hook. So you should make sure your script … Read more

What are best practices for configuring a server for WordPress sites?

It’s a very loaded question, I’ll try my best here, keep in mind it’s 4am, so I’m just giving you highlights, not detailed explanations. Linux I’m assuming you’re using a recent version of Ubuntu Change the default SSH port from 22, to something else (/etc/ssh/sshd_config). Either enable AllowGroups or AllowUser in the sshd_config, Install fail2ban … Read more

Is it useful to turn on MySQL query cache for performance

General speaking yes for read-only applications (until MySQL 5.7, it’s deprecated since version 8.0), it enables equal SELECTs to return data extremely fast if identical calls are already stored in cache. You should consider that: Only exact same clauses can benefit from the cache engine (no spaces, no comments, no actual differences in WHERE expressions); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)