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
Otomaties\AcfObjects\AcfObjectsServiceProvider::class
add_filter('acf/format_value', function ($value, $post_id, $field) {
$value = \Otomaties\AcfObjects\Acf::findClassByFieldType($value, $post_id, $field);
return $value;
}, 99, 3);
use Otomaties\AcfObjects\Acf;
if(Acf::getField('fieldname')->isSet()):
if(!Acf::getField('fieldname')->isEmpy()):
echo Acf::getField('date')->format('d/m/Y');
echo Acf::getField('file')->url();
<ul>
foreach (Acf::getField('gallery') as $image):
echo Acf::getField('gallery')[1]->image();
echo Acf::getField('google_map')->address();
echo Acf::getField('group')->get('text');
echo Acf::getField('image')->url('medium');
echo Acf::getField('image')->image('medium');
<a href=" echo Acf::getField('image')->url('full');
echo Acf::getField('image')->default(48, 'thumbnail')->image('thumbnail');
echo Acf::getField('image')->default('https://picsum.photos/150/150')->image('thumbnail');
echo Acf::getField('link')->link(); // Will output an a-tag with href, target & title
echo Acf::getField('link')->attributes(['class' => 'btn btn-primary','data-foo' => 'bar'])->link();
<a href=" echo Acf::getField('link')->url();
<table class="table">
foreach (Acf::getField('repeater') as $key => $row):
if (isset(Acf::getField('repeater')[0])):
echo Acf::getField('text');
echo Acf::getField('text')->default('Default text');
echo Acf::getField('text', 51);