Skip to content

Instantly share code, notes, and snippets.

@dividezigns
dividezigns / single-template_name.php
Last active June 19, 2018 23:39
This code will use ACF's relationship field to display a WP Forms. Place this code snippet in your single template file located in your child theme directory.
<?php
$posts = get_field('wp_forms');
if( $posts ):
foreach( $posts as $post):
$form_id = get_the_ID();
echo do_shortcode('[wpforms id="' . $form_id . '"]');
endforeach;
wp_reset_postdata();
endif;
@dividezigns
dividezigns / single-template_name.php
Last active February 15, 2023 16:53
This code will use ACF's galley field with Divi's native gallery module. Place this code snippet in your single template file located in your child theme directory.
<?php
$columnNumber++
?>
<div class="et_pb_row et_pb_row_<?php echo $columnNumber++ ?> et_pb_gutters2 wcf_gallery_row">
<div class="et_pb_column et_pb_column_4_4 et_pb_column_<?php echo $columnNumber++ ?>">
<div class="et_pb_module et_pb_gallery et_pb_gallery_<?php echo $columnNumber++ ?> et_pb_gallery_grid et_pb_bg_layout_light clearfix">
<div class="et_pb_gallery_items et_post_gallery clearfix" data-per_page="20">
<?php
@dividezigns
dividezigns / functions.php
Created May 30, 2018 02:35
This code will hide the WordPress editor bases on a custom template. Good if you're using your own fields. You can add this code snippet to your functions.php file in your child theme directory.
<?php
add_action( 'admin_head', 'hide_editor' );
function hide_editor() {
$template_file = basename( get_page_template() );
if($template_file == 'template-name.php'){
remove_post_type_support('page', 'editor');
}
}
@dividezigns
dividezigns / Template or Page
Last active May 27, 2018 17:48
Add custom shortcode inside template file
// This shortcode is placed in any template file
<?php echo do_shortcode("[featured-project]"); ?>
// This shortcode is placed in WordPress page
[featured-project]
@dividezigns
dividezigns / Enqueue other styles and scripts
Created May 27, 2018 04:04
This code will load other style.css files and js scripts. Place this code in the functions.php file in your child theme directory.
<?php
add_action( 'wp_enqueue_scripts', 'my_assets' );
function my_assets() {
wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'fancy-box-css', get_stylesheet_directory_uri() . '/css/jquery.fancybox.css' );
wp_enqueue_script( 'fancy-box-script', get_stylesheet_directory_uri() . '/js/jquery.fancybox.js', array( 'jquery' ) );
}
@dividezigns
dividezigns / Replace List Bullets with Divi Icons
Last active May 6, 2018 05:35
This code will replace the standard HTML list bullets and with any Divi icon. Place code in style.css file in your child theme directory.
.custom_bullets ul {
padding-bottom: 20px;
}
.custom_bullets li {
padding-left: 15px;
padding-bottom: 0em;
list-style-type: none;
}
@dividezigns
dividezigns / Fullwidth Divi Mobile Menu
Last active May 6, 2018 05:14
This code will force Divi's mobile menu to expand fullwidth. Place this code in style.css file in your child theme directory.
.container.et_menu_container {
width: calc( 100% - 60px);
}
.et_mobile_menu {
margin-left: -30px;
padding: 5%;
width: calc( 100% + 60px);
}
@dividezigns
dividezigns / List of Social Media Icon Classes for Divi's Secondary Navigation
Last active May 6, 2018 05:44
These Divi classes will give you more social media icon option in footer and secondary navigation.
.et-social-facebook
.et-social-twitter
.et-social-google-plus
.et-social-pinterest
.et-social-linkedi
.et-social-tumblr
.et-social-instagram
.et-social-skype
.et-social-flikr
@dividezigns
dividezigns / Enqueue Child Theme
Last active May 6, 2018 05:10
This code will load your child theme style.css file. Place this code in your child themes functions.php to Enqueue Child Theme.
<?php
add_action( 'wp_enqueue_scripts', 'my_child_theme_scripts' );
function my_child_theme_scripts() {
wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' );
}
@dividezigns
dividezigns / New Breakpoint For Mobile Menu
Last active May 6, 2018 05:25
This code will change the break point to reveal Divi's mobile menu. Place this code in style.css file in your child theme directory.
@media (max-width: 1024px) {
#et_mobile_nav_menu {
display: block;
}
#top-menu {
display: none;
}