Skip to content

Instantly share code, notes, and snippets.

@dividezigns
dividezigns / Custom Shortcode for Archive Loop
Last active May 27, 2018 17:49
This code will make a shortcode that you can place any where on a page to render a custom post type archive. Place this code in your functions.php in your child theme's directory.
<?php
function get_featured_project(){
ob_start();
$paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
$featured_project = new WP_Query(array(
@dividezigns
dividezigns / Custom Post Type Archive Template for Divi
Last active April 17, 2023 03:10
This template can be used as an archive page for a custom post type in Divi. Create a file and name it archive-your_custom_post_name.php. and place it in your child theme's directory.
<?php
/* =====
Template Name: Custom Post Type Archive
===== */
get_header();
@dividezigns
dividezigns / Add a hover effect to Divi's navigation bar
Last active May 6, 2018 04:58
This code will add a hover effect to Divi's navigation bar. Place this code snippet in your style.css file in your child theme.
#top-menu a:hover::before,
#top-menu a:hover::after,
#top-menu a:focus::before,
#top-menu a:focus::after {
opacity: 1;
-webkit-transform: translateX(0px);
-moz-transform: translateX(0px);
transform: translateX(0px);
}
@dividezigns
dividezigns / Enable SVG upload
Last active April 5, 2022 13:32
This code will enable SVG upload in WordPress. Place this code in your functions.php file in the child theme directory.
<?php
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
@dividezigns
dividezigns / Control Opacity on Divi's Navigation Bar
Last active May 5, 2018 17:26
This code will target the opacity on Divi's navigation bar links. Place this code inside your style.css file in your child theme's directory.
#et-info-email:hover,
#et-secondary-menu > ul > li > a:hover,
#top-menu-nav > ul > li > a:hover,
.et-social-icons a:hover {
opacity: 1;
-webkit-transition: all .4s ease-in-out;
-moz-transition: all .4s ease-in-out;
transition: all .4s ease-in-out;
}
@dividezigns
dividezigns / Remove "Projects" Custom Post Type from Divi
Last active May 6, 2018 05:30
This code will remove Divi's Projects custom post type. Place this code in functions.php file in your child theme directory.
<?php
add_filter( 'et_project_posttype_args', 'mytheme_et_project_posttype_args', 10, 1 );
function mytheme_et_project_posttype_args( $args ) {
return array_merge( $args, array(
'public' => false,
'exclude_from_search' => false,
'publicly_queryable' => false,
'show_in_nav_menus' => false,
@dividezigns
dividezigns / Change default "Select Page" in Divi mobile menu
Created May 5, 2018 04:04
This code will give you the ability to change Divi's default "Select Page" to whatever you want. Place this code in your functions.php file.
<?php
add_filter('gettext', 'change_select_page_text', 20, 3);
function change_select_page_text($text, $orig, $domain ) {
if ($domain == 'Divi' and $orig == 'Select Page') { return 'Menu'; }
return $text;
}
@dividezigns
dividezigns / Nesting Sub Menu Items in Divi's Mobile Menu (CSS)
Last active May 6, 2018 06:05
This code is 1 of 2 parts needed to nest sub menu items in Divi. Place this code in style.css file in your child theme directory.
#main-header .et_mobile_menu .menu-item-has-children>a {
background-color: transparent;
position: relative;
}
#main-header .et_mobile_menu .menu-item-has-children>a:after {
font-family: 'ETmodules';
text-align: center;
speak: none;
@dividezigns
dividezigns / Nesting Sub Menu Items in Divi's Mobile Menu (JS)
Last active May 6, 2018 05:22
This code is 2 of 2 parts needed to nest sub menu items in Divi. Place this code in style.css file in your child theme directory.
<script type="text/javascript">
(function($) {
function setup_collapsible_submenus() {
var $menu = $('#mobile_menu'),
top_level_link = '#mobile_menu .menu-item-has-children > a';
$menu.find('a').each(function() {
$(this).off('click');
@dividezigns
dividezigns / Turn Divi mobile menu icon to "X" if clicked
Last active May 6, 2018 05:49
Turn Divi mobile menu icon to "X" when clicked. Place this code in style.css file in your child theme directory.
.mobile_nav.opened .mobile_menu_bar:before {
content: "\4d";
}