Skip to content

Instantly share code, notes, and snippets.

View iamchetanp's full-sized avatar
🏠
Working from home

Chetan Prajapati iamchetanp

🏠
Working from home
View GitHub Profile
/**
* Get all image sizes.
*/
function cp_get_all_image_sizes() {
global $_wp_additional_image_sizes;
print '<pre>';
print_r( $_wp_additional_image_sizes );
print '</pre>';
}
add_action( 'init', 'cp_get_all_image_sizes' );
@iamchetanp
iamchetanp / functions.php
Created January 24, 2020 20:59
Divi Theme - Remove extra image sizes
/**
* Remove extra image sizes
*
* @param array $sizes Array of image sizes.
*/
function cpdivi_remove_extra_image_sizes( $sizes ) {
unset( $sizes['et-pb-post-main-image'] );
unset( $sizes['et-pb-post-main-image-fullwidth'] );
unset( $sizes['et-pb-portfolio-image'] );
unset( $sizes['et-pb-portfolio-module-image'] );
@iamchetanp
iamchetanp / style.css
Created December 5, 2019 19:46
Divi Theme - Responsive Menu
#main-header #et-top-navigation {
float: none;
padding: 0;
}
#top-menu-nav {
display: none;
}
#et_mobile_nav_menu {
@iamchetanp
iamchetanp / favicon.php
Created November 21, 2019 19:29
Add Favicon
/**
* Add Favicon
*/
function cpdivi_custom_favicon() {
$favicon_path = get_stylesheet_directory_uri() . '/img/favicon/';
ob_start();
?>
<link rel="shortcut icon" href="<?php echo esc_attr( $favicon_path ); ?>favicon.ico" />
<link rel="apple-touch-icon-precomposed" sizes="57x57" href="<?php echo esc_attr( $favicon_path ); ?>apple-touch-icon-57x57.png" />
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="<?php echo esc_attr( $favicon_path ); ?>apple-touch-icon-114x114.png" />
@iamchetanp
iamchetanp / posts.php
Created November 11, 2019 15:52
Related Posts
//shortcode related products
add_shortcode('related_products','rel_prod');
function rel_prod(){
global $post;
ob_start();
?>
<div class="section section-post-related">
<div class="section_wrapper clearfix">
@iamchetanp
iamchetanp / recent-posts.php
Created October 22, 2019 18:27
Recent Posts1=
<?php
/**
* Shortcode for posts
*
* @package Divi
*/
$posts_args = array(
'post_type' => 'post',
'posts_per_page' => '3',
@iamchetanp
iamchetanp / functions.php
Created July 12, 2019 19:47
Disable Project Post Type in Divi Theme.
/**
* Remove portfolio post type from theme
*
* @param array $args post type array.
*/
function cpdivi_et_project_posttype_args( $args ) {
return array_merge(
$args,
array(
'public' => false,
@iamchetanp
iamchetanp / functions.php
Created June 26, 2019 10:52
Title function for WordPress
/**
* Return title based on current page, post, taxonomy, post type, category, tag etc.
*/
function cpdivi_title() {
if ( is_home() ) {
$page_for_posts = get_option( 'page_for_posts' );
$title = sprintf( __( '%s', 'cpdivi' ), get_the_title( $page_for_posts ) );
} elseif ( is_category() ) {
/* translators: 1: category title. */
$title = sprintf( __( 'Category: %s', 'cpdivi' ), single_cat_title( '', false ) );
@iamchetanp
iamchetanp / login.php
Last active March 19, 2019 10:03
Better WordPress Login Page
<?php
/**
* CSS rules for WordPress Login page.
*
* @package ChetanP
*/
/**
* CSS for wp-login.php page
*/
@iamchetanp
iamchetanp / .htaccess
Created December 16, 2018 21:33
Redirect non-www URLs to www with https (Apache)
# Redirect non-www URLs to www with https
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]