Skip to content

Instantly share code, notes, and snippets.

@crawford252
crawford252 / functions.php
Last active July 13, 2020 20:46
Divi FilterGrid - Custom Loader
function dpdfg_custom_loader() {
ob_start();
?>
<div class="dp-dfg-loader">[insert your loader HTML here]</div>
<style>
/* ADD YOUR LOADER'S CSS HERE */
</style>
<?php
@crawford252
crawford252 / functions.php
Created July 13, 2020 20:29
Divi FilterGrid - Custom Loader Full Example
function dpdfg_custom_loader() {
ob_start();
?>
<div class="dp-dfg-loader"><div class="my_custom_loader"></div></div>
<style>
.dp-dfg-loader {
position: absolute;
top: 50%;
left: 50%;
margin-top: -30px;
@crawford252
crawford252 / functions.php
Last active October 26, 2020 14:30
Divi FilterGrid - Related Posts (Categories)
// DFG CUSTOM QUERY - RELATED POSTS
function dpdfg_custom_query($query_args, $props) {
if (isset($props['module_class']) && $props['module_class'] == "dfg-related-posts") {
$current_post_id = $props['the_ID'];
$terms_of_current_post = get_the_terms($current_post_id, 'category');
$terms_ids = array();
foreach ($terms_of_current_post as $term_object) {
$terms_ids[] = $term_object->term_id;
}
return array(
@crawford252
crawford252 / functions.php
Last active July 15, 2020 15:10
Divi FilterGrid - Custom Content Simple Example
function dpdfg_after_read_more() {
return '<a class="button et_pb_button" href="#">Click Me</a>';
}
add_filter('dpdfg_after_read_more', 'dpdfg_after_read_more');
@crawford252
crawford252 / functions.php
Last active April 4, 2022 12:07
Divi FilterGrid - Custom Content Custom Field Example
function dpdfg_after_read_more() {
$custom_field = get_post_meta( get_the_ID(), 'my_custom_field', true );
return '<a class="button et_pb_button" href="'.$custom_field.'">CLICK ME</a>';
}
add_filter('dpdfg_after_read_more', 'dpdfg_after_read_more');
@crawford252
crawford252 / functions.php
Last active July 15, 2020 15:11
Divi FilterGrid - Custom Content Output Changes Based on Module ID
function dpdfg_after_read_more($content, $props) {
if (isset($props['module_id']) && $props['module_id'] === 'custom-content') {
return '<a class="button et_pb_button" href="#">Click Me</a>';
} else {
return 'This module does not have CSS ID custom-content';
}
}
add_filter('dpdfg_after_read_more', 'dpdfg_after_read_more', 10, 2);
@crawford252
crawford252 / functions.php
Created July 15, 2020 15:14
Divi FilterGrid - Custom Content Shortcode Output
function dpdfg_after_read_more() {
ob_start();
echo do_shortcode('[your_shortcode_handle]');
return get_ob_clean();
}
add_filter('dpdfg_after_read_more', 'dpdfg_after_read_more');
@crawford252
crawford252 / functions.php
Created July 16, 2020 18:56
Owl Carousel Pro - Custom Content Simple Example
function dp_ocp_custom_content() {
return '<a class="button et_pb_button" href="#">Click Me</a>';
}
add_filter('dp_ocp_custom_content', 'dp_ocp_custom_content');
@crawford252
crawford252 / functions.php
Created July 16, 2020 18:59
Owl Carousel Pro - Custom Content Custom Field Example
function dp_ocp_custom_content() {
$custom_field = get_post_meta( get_the_ID(), 'my_custom_field', true );
return '<a class="button et_pb_button" href="#">'.$custom_field.'</a>';
}
add_filter('dp_ocp_custom_content', 'dp_ocp_custom_content');
@crawford252
crawford252 / functions.php
Created July 16, 2020 19:01
Owl Carousel Pro - Custom Content Output Changes Based on Module ID
function dp_ocp_custom_content($content, $props) {
if (isset($props['module_id']) && $props['module_id'] === 'custom-content') {
return '<a class="button et_pb_button" href="#">Click Me</a>';
} else {
return 'This module does not have CSS ID custom-content';
}
}
add_filter('dp_ocp_custom_content', 'dp_ocp_custom_content', 10, 2);