Skip to content

Instantly share code, notes, and snippets.

//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 / Conditionally_display CPT_based_on_post_object_field.php
Last active November 8, 2020 11:43
If you trying to query the post object field to between 2 CPT's. This condition checks if the repeater is empty or not.
// Add the function to advanced scripts (or code snippet)
// Create a condition in the builder to the section where you want to hide
// Select dynamic data -> php function -> “Check_CPT_Repeater”
// Inside the arguments section add your "cpt_name" and post object "acf_field"
// Set dynamic data == 0 (to hide if no results are returned)
function Check_CPT_Repeater( $cpt_name, $acf_field ){
//WP_Query arguments
$args = array(
<?php
/**
* Function to check if the current Page is a parent or not.
* @return bool true (1) if the current Page has children else false (0)
*/
function wpdd_is_parent_page() {
// Load details about this page.
$post = get_post();
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.
<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>
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>';
function my_acf_shortcode( $atts ){
$atts = shortcode_atts( array(
'field' => '',
'image' => ''
), $atts, 'showfield' );
if ( get_field( $atts['field'] ) && ( $atts['image'] !== '' ) ) :
return '<a href="' . get_field( $atts['field'] ) . '"><img src="' . $atts['image'] . '"></a>';
endif;
}
/*Image Overlay on Hover*/
.image-overlay{
position: relative;
cursor: pointer;
}
.text-colour a{
color:black;
}
.image-overlay:after {
content: "";
// 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' );