View functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wpdev_156674_pre_get_posts( $query ) { | |
if ( | |
$query->is_main_query() | |
&& $query->is_tax( 'region' ) | |
) { | |
// Manipulate $query here, for instance like so | |
$query->set( 'orderby', 'meta_value_num' ); | |
$query->set( 'meta_key', 'event_date' ); | |
$query->set( 'order', 'DESC' ); |
View how-to-update-acf-google-map-field.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// The field accepts a value with this structure | |
$value = [ | |
'address' => '123 Example St, Townsville XYZ 1234, Country', | |
'lat' => - 38.1486228, | |
'lng' => 144.360414, | |
'zoom' => 14, | |
'place_id' => 'Ei0xMjMgTW9vcmFib29sIFN0LCBHZWVsb25nIFZJQyAzMjIwLCBBdXN0cmFsaWEiMBIuChQKEgmX0JaIHBTUahFyH_LC9sYD8hB7KhQKEglDz-DYDxTUahECZY8QisCjzg', | |
'street_number' => 123, |
View register-acf-options-page.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// register a top-level options page | |
if ( function_exists( 'acf_add_options_page' ) ) { | |
acf_add_options_page( [ | |
'page_title' => 'My Options Page', | |
'menu_title' => 'My Options Page', | |
'menu_slug' => 'my-options-page', | |
'capability' => 'edit_posts', | |
'parent_slug' => '', |
View load-flexi-field-layout-partials-in-templates.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// In a post/page template, loop over the ACF flexible field layouts and load the partial | |
// responsible for rendering the layout. | |
while ( the_flexible_field('my_flexi_field') ) { | |
get_template_part( 'components/'. get_row_layout() ); | |
} |
View define-google-maps-api-key-for-acf.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Define this in the site's wp-config.php file. | |
define('GOOGLE_API_KEY', 'your-google-api-key-here'); | |
// Add this to your functions.php file, or a config plugin/MU plugin. | |
add_filter( 'acf/fields/google_map/api', function ( $api ) { | |
$api['key'] = GOOGLE_API_KEY; | |
return $api; |
View disable-core-meta-metabox.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('acf/settings/remove_wp_meta_box', '__return_true'); |
View acf-php-license-config.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add this in your wp-config.php file | |
define('ACF_PRO_LICENSE', '{YOUR LICENSE KEY HERE}' ); | |
View acf-field-group-php-to-json.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get all the local field groups and loop through them for processing. | |
$field_groups = acf_get_local_field_groups(); | |
foreach ( $field_groups as $group ) { | |
// If the field group has fields, load them into the 'fields' key. | |
if ( acf_have_local_fields( $group['key'] ) ) { | |
$group['fields'] = acf_get_local_fields( $group['key'] ); | |
} |
View register-acf-json-load-directory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'acf/settings/load_json', function ( $paths ) { | |
$paths[] = get_template_directory() . '/some/custom/dir'; | |
return $paths; | |
} ); |
NewerOlder