Skip to content

Instantly share code, notes, and snippets.

function list_child_pages() {
global $post;
if ( is_page() && $post->post_parent )
$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' );
else
$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' );
if ( $childpages ) {
$string = '<ul>' . $childpages . '</ul>';
<div <?php post_class( get_the_ID() == get_queried_object_id() ? 'oxy-post current-post' : 'oxy-post'); ?>>
<a class='oxy-post-title' href='<?php the_permalink(); ?>'><?php the_title(); ?></a>
</div>
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
/**
* Change the length of excerpt.
*
* @param int $length The number of words. Default 55.
* @return int New excerpt length.
*/
function custom_excerpt_length( $length ) {
return 20; // number of words. Default is 55.
<?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; ?>
.wp-grid-builder .wpgb-sidebar {
position: sticky;
flex-basis: 50%;
height: 100vh;
top: 0;
}
.wp-grid-builder .wpgb-main {
overflow: hidden;
padding: 3em 4em;
}
/**
* 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
//PHP Custom Code - plugins loaded
if ( function_exists( 'acf_add_options_page' ) ) {
acf_add_options_page();
}
function tct_field($field_name) {
return get_field( $field_name, 'option' );
}
@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 );
@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',