Skip to content

Instantly share code, notes, and snippets.

<?php
//Add dynamic class to posts
//dynamic_classes_oxygen_repeater.php
//Add this into a codeblock
<style type="text/css">
.post-<?php the_ID() ?> #DIV_ID_HERE{
background-color:<?php the_field('ACF_FIELD_HERE'); ?>;
}
@tdrayson
tdrayson / update_acf_date_field.php
Last active October 27, 2020 20:44
Update an ACF Field based on if the date is in the past.
function tct_set_new_date() {
$posts = get_posts( array('post_type' => 'session', 'posts_per_page' => - 1) );
$current_date = date( "Y-m-d h:i" );
foreach($posts as $post) {
$old_date = get_field( 'date', $post->ID );
if($old_date < $current_date) {
$new_date = date( 'Y-m-d h:i', strtotime( '+1 week', strtotime( $old_date ) ) );
update_field( 'date', $new_date, $post->ID );
/**
* Display a custom taxonomy dropdown in admin
* @author Mike Hemberger
* @link http://thestizmedia.com/custom-post-type-filter-admin-custom-taxonomy/
*/
add_action('restrict_manage_posts', 'tsm_filter_post_type_by_taxonomy');
function tsm_filter_post_type_by_taxonomy() {
global $typenow;
$post_type = 'team'; // change to your post type
$taxonomy = 'group'; // change to your taxonomy
.wp-grid-builder .wpgb-sidebar {
position: sticky;
flex-basis: 50%;
height: 100vh;
top: 0;
}
.wp-grid-builder .wpgb-main {
overflow: hidden;
padding: 3em 4em;
}
<?php
$link = get_field('gmb_url');
if( $link ): ?>
<iframe src="<?php echo esc_url( $link ); ?>" width="1200" height="900" frameborder="0" style="border:0;" allowfullscreen=""></iframe>
<?php endif; ?>
@tdrayson
tdrayson / Relationship_field_is_not_empty.php
Last active October 28, 2020 15:45
Conditionally show a section in Oxygen based on if the CPT has posts attached to it via post object field.Links CPT's and display on frontend using post object field - https://gist.github.com/tdrayson/0b915b4d89615ca663f2bd1f03e0f364Add condition
function check_query_field( $cpt_name, $acf_field ){ //Put CPT as function name
//WP_Query arguments
$args = array(
'post_type' => array( $cpt_name ),//CPT NAME Here
'meta_query' => array(
array(
'key' => $acf_field, //ACF FIELD NAME HERE
'value' => get_the_ID(),
'compare' => 'LIKE',
//Set the repeater to 100% width
// Set display:block
// Add the below to custom css in repeater
-webkit-column-count: 4;
-moz-column-count: 4;
column-count: 4;
// Set Div inside repeater to display:block
//Add the below to the custom css
// remove update notice for forked plugins
function remove_update_notifications($value) {
if ( isset( $value ) && is_object( $value ) ) {
unset( $value->response[ plugin_basename(__FILE__) ] );
}
return $value;
}
add_filter( 'site_transient_update_plugins', 'remove_update_notifications' );
/*Image Overlay on Hover*/
.image-overlay{
position: relative;
cursor: pointer;
}
.text-colour a{
color:black;
}
.image-overlay:after {
content: "";