PHP code example of tombroucke / acf-objects

1. Go to this page and download the library: Download tombroucke/acf-objects 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/ */

    

tombroucke / acf-objects example snippets


$checkboxValues = AcfObjects::getField('checkbox');

AcfObjects::getField('date')

AcfObjects::getField('date_time')

  $settings = AcfObjects::getField('settings')
    ->default([
      'foo' => 'bar'
    ]);

  echo $settings->get('foo');

AcfObjects::getField('repeater')
blade
@foreach (AcfObjects::getField('gallery') as $image)
  <a href="{{ $image->url('large') }}">
    {!! $image->image('medium') !!}
  </a>
@endforeach
blade
{!!
AcfObjects::getField('image')
  ->url('medium');
!!}

{!!
AcfObjects::getField('image')
  ->attributes(['class' => 'w-100 h-100 object-fit-cover'])
  ->image('thumbnail');
!!}

{!!
AcfObjects::getField('image')
  ->default(asset('image/placeholder.jpg')->uri())
  ->image('thumbnail');
!!}
blade
{{ AcfObjects::getField('text')->default(get_the_title()) }}