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 | |
// http://php.net/manual/en/function.date.php | |
//get the time from the ACF time picker see php.net for date formats | |
$printdate = DateTime::createFromFormat('Ymd', get_post_meta($post->ID, 'event_date', 'true')); //event_date from custom feild | |
$eventDate = $printdate->format('m/d/Y'); | |
if (time() < strtotime("$eventDate 11:59PM")) { ?> | |
<!-- the date has not passed SHOW CONTENT --> | |
<?php } else { ?> | |
<!-- SORRY the date has passed already--> |
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 | |
//check for refering page to switch content based on referrer | |
$referrer = $_SERVER['HTTP_REFERER']; | |
if ($referrer == 'http://url.com' or $referrer == 'http://url-2.com') { | |
//Matches YES! | |
} else { | |
//Matches NO! | |
header( 'Location: http://www.url.com/no-soup-for-you/' ) ; |
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
//Excerpt with formating from WYSIWYG | |
function improved_trim_excerpt($text) { | |
global $post; | |
if ( '' == $text ) { | |
$text = get_the_content(''); | |
$text = apply_filters('the_content', $text); | |
$text = str_replace('\]\]\>', ']]>', $text); | |
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text); | |
//$text = strip_tags($text, '<p>'); | |
$excerpt_length = 70; |
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
<h1> | |
<?php if (is_singular('your_cpt') || is_archive('your_cpt') || is_post_type_archive('your_cpt') ) { ?> | |
YOUR CPT NAME | |
<?php } elseif (is_search()) { ?> | |
Search | |
<?php } elseif (is_404()) { ?> | |
Error 404 | |
<?php } else { ?> | |
<?php the_field('headline_text'); ?> | |
<?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 remove_acf_menu() | |
{ | |
// provide a list of usernames who can edit custom field definitions here | |
$admins = array( | |
'admin', | |
'levy-admin', | |
'barb' | |
); |
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
{ | |
"title": "JSON schema for WordPress blocks", | |
"$schema": "http://json-schema.org/draft-04/schema#", | |
"definitions": { | |
"//": { | |
"reference": "https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/", | |
"attributesReference": "https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/", | |
"contextReference": "https://developer.wordpress.org/block-editor/reference-guides/block-api/block-context/", | |
"supportsReference": "https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/", | |
"registerReference": "https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/#example-optional" |
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 | |
// Create an empty array for storage | |
$post_data = array(); | |
// Set arguments for your query | |
$args = array( | |
'post_type' => 'trips', | |
'posts_per_page' => 999 | |
); |
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 | |
$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 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 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'), |