This file contains hidden or 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 | |
$content = get_post_meta($post->ID, your_custom_field_meta, true); | |
$trimmed_content = wp_trim_words($content, 15, '... <a href="' . get_permalink() . '">Read More</a>'); | |
echo $trimmed_content; | |
?> | |
This file contains hidden or 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 echo get_option('home'); ?> <!-- get the home URL --> | |
<?php bloginfo('description'); ?> <!-- display the blog description --> | |
<?php bloginfo('name'); ?> <!-- display the blog name --> | |
<?php bloginfo('template_directory') ?> <!-- get the home URL for template's directory --> | |
<?php echo get_template_directory_uri(); ?> | |
<?php wp_list_pages('sort_order=desc&title_li='); ?> <!-- display the page list in descending order withour title --> | |
<?php wp_list_pages('sort_order=desc&depth=1&title_li='); ?> <!-- display the page list in descending order with "current_page_item" class | |
<?php wp_list_bookmarks(); ?> <!-- display the list of blogrolls --> | |
<?php echo date('Y'); ?> |
This file contains hidden or 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_action('acf/render_field_settings/type=text', 'add_readonly_and_disabled_to_text_field'); | |
function add_readonly_and_disabled_to_text_field($field) { | |
acf_render_field_setting( $field, array( | |
'label' => __('Read Only?','acf'), | |
'instructions' => '', | |
'type' => 'radio', | |
'name' => 'readonly', | |
'choices' => array( | |
1 => __("Yes",'acf'), |
This file contains hidden or 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 RULE TO SECTION | |
add_filter('acf/location/rule_types', 'acf_location_rules_types'); | |
function acf_location_rules_types( $choices ) | |
{ | |
$choices['Other']['taxonomy_depth'] = 'Taxonomy Depth'; | |
return $choices; | |
} | |
//MATCHING OPERATORS |
This file contains hidden or 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 | |
/** | |
* Plugin Name: Field Group Location: Post Type Supports | |
* Plugin URI: http://qwp6t.me/acf-post-type-supports | |
* Description: Adds ACF Field Group location rule for Post Type Support. NOTE: You must first declare the supported feature in your theme. | |
* Version: 1.0.0 | |
* Author: QWp6t | |
* Author URI: http://qwp6t.me | |
* License: MIT License | |
*/ |
This file contains hidden or 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 | |
/** | |
* Created by PhpStorm. | |
* User: Matteo | |
* Date: 04/07/2018 | |
* Time: 12:52 | |
*/ | |
/** | |
* Class ACFToArray |
This file contains hidden or 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 | |
/** Create Title and Slug */ | |
function acf_title( $value, $post_id, $field ) { | |
if ( get_post_type( $post_id ) === 'staff' ) { | |
$new_title = get_field( 'first_name', $post_id ) . ' ' . $value; | |
$new_slug = sanitize_title( $new_title ); | |
wp_update_post( | |
array( |
This file contains hidden or 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 | |
function acf_sync_field( $sync_field, $value, $post_id, $field ){ | |
// vars | |
$source_field = $field['name']; | |
$source_global_name = 'is_updating_' . $source_field; | |
$sync_global_name = 'is_updating_' . $sync_field; | |
// get this value early before anything is updated |
This file contains hidden or 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 | |
// ================================================================= | |
// ====== Custom admin + menus | |
// ================================================================= | |
/* Theme support for menus */ | |
add_theme_support( 'menus' ); | |
// Remove width and height attributes from images via WYSIWYG/admin |
This file contains hidden or 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 | |
/** | |
* Set excerpt from ACF field | |
*/ | |
add_action('acf/save_post', function($post_id) { | |
$post_excerpt = get_field( 'short_description', $post_id ); | |
if ( ( !empty( $post_id ) ) AND ( $post_excerpt ) ) { |