PHP code example of nickford / acf-swatch

1. Go to this page and download the library: Download nickford/acf-swatch library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nickford / acf-swatch example snippets


/**
 * Include ACF Color Swatch Field
 */

add_filter('acf/swatch_settings/path', 'my_swatch_path', 10, 1);

function my_swatch_path( $path ) {
  
  $path = get_template_directory() . '/path/to/acf-swatch';
  
  return $path;
  
}

add_filter('acf/swatch_settings/url', 'my_swatch_url', 10, 1);

function my_swatch_url( $url ) {
  
  $url = get_template_directory_uri() . '/path/to/acf-swatch';
  
  return $url;
  
}

html
<section style="background-color:  the_field('swatches')
html
<style>
section {
  background-color:  the_field('swatches')
html
<style>
section {
  background: linear-gradient(
                to bottom,
                rgba( the_field('swatches')