Skip to content

Instantly share code, notes, and snippets.

View wpgaurav's full-sized avatar
👋
Hello!

Gaurav Tiwari wpgaurav

👋
Hello!
View GitHub Profile
@wpgaurav
wpgaurav / sticky-coupons.php
Created June 8, 2021 08:46
Sticky Coupons
<h2 class="text-center block-single-tb">
Featured Tools and Services
</h2>
<?php
// the query
$sticky = get_option( 'sticky_posts' );
$the_query = new WP_Query( array(
'post_type' => 'coupon',
'posts_per_page' => 6,
'post__in' => $sticky,
<!doctype html><html amp i-amphtml-binding i-amphtml-layout i-amphtml-no-boilerplate lang=en-US prefix="og: https://ogp.me/ns#" transformed="google;v=7"><head><meta charset=UTF-8><style amp-runtime i-amphtml-version=012108052321001>html{overflow-x:hidden!important}html.i-amphtml-fie{height:100%!important;width:100%!important}html:not([amp4ads]),html:not([amp4ads]) body{height:auto!important}html:not([amp4ads]) body{margin:0!important}body{-webkit-text-size-adjust:100%;-moz-text-size-adjust:100%;-ms-text-size-adjust:100%;text-size-adjust:100%}html.i-amphtml-singledoc.i-amphtml-embedded{-ms-touch-action:pan-y pinch-zoom;touch-action:pan-y pinch-zoom}html.i-amphtml-fie>body,html.i-amphtml-singledoc>body{overflow:visible!important}html.i-amphtml-fie:not(.i-amphtml-inabox)>body,html.i-amphtml-singledoc:not(.i-amphtml-inabox)>body{position:relative!important}html.i-amphtml-ios-embed-legacy>body{overflow-x:hidden!important;overflow-y:auto!important;position:absolute!important}html.i-amphtml-ios-embed{overflow-y:auto
@wpgaurav
wpgaurav / post-prev-next.php
Last active March 24, 2023 21:16
Dynamic Month and Year Support in all CodeSupply Themes, sampled from SquareType. Replace template-parts/post-prev-next.php file with this code in you child or parent theme.
<?php
/**
* The template part for displaying post prev next section.
*
* @package Squaretype
*/
$prev_post = get_previous_post();
$next_post = get_next_post();
<?php
#-----------------------------------------
# RT-Theme rt_breadcrumb.php
#-----------------------------------------
add_action("rt_breadcrumb_menu", "rt_breadcrumb", 10, 1 );
/* RT-Breadcrumb Function */
if( ! function_exists('rt_breadcrumb') ){
function rt_breadcrumb(){?>
@wpgaurav
wpgaurav / load-css.html
Created September 24, 2021 05:51
Load CSS on Button Click - Useful for DarkMode config
<link id="custom_stylesheet" rel="stylesheet" type="text/css" href="" />
<script>
function LoadStyleAndScript()
{
$("#custom_stylesheet").attr("href", "//example.com/mystyle.css");
}
</script>
<input type="button" onClick="LoadStyleAndScript();" value="Load it">
/**
* Create shortcode for donate box.
*
* @since 1.0
*/
function md_child_donate_shortcode( $atts ) {
ob_start();
?>
<form action="https://www.paypal.com/donate" method="post" target="_top" class="text-center mb-half">
@wpgaurav
wpgaurav / dark.css
Last active June 1, 2022 16:15
Customizer CSS for Marketers Delight that enables a beautiful Dark Mode on gauravtiwari.org
@media (prefers-color-scheme: dark) {
.aawp .aawp-tb__row--highlight {
background-color: #219b00;
color: #fff;
}
.aawp .aawp-tb__row--highlight a, h4.pt-cv-title a {
color: #fff;
}
.logopatch3,.logopatch4,.logopatch5{
@wpgaurav
wpgaurav / md-custom-image-sizes.php
Last active May 11, 2022 04:27
Add Marketers Delight / MD Image Sizes to Gutenberg Image Block
/* Add MD Image Sizes to Gutenberg Image Block */
add_filter( 'image_size_names_choose','md_custom_image_sizes' );
function md_custom_image_sizes( $sizes ) {
return array_merge( $sizes, array(
//Add your custom sizes here
'md-full' => __( 'MD Full' ),
'md-banner' => __( 'MD Banner' ),
'md-block' => __( 'MD Block' ),
'md-thumbnail' => __( 'MD Thumb' ),
@wpgaurav
wpgaurav / 1-menu-customize.css
Last active August 23, 2022 07:32
Making Marketers Delight 100% Accessible : Use tab buttons on https://gauravtiwari.org to see it in action.
@media screen and (min-width:800px){
.menu-item-has-children:hover .sub-menu, .menu-item-has-children:focus > .sub-menu, .menu-item-has-children:focus-within .sub-menu{
display: grid ; /* You can also use block or flex here */
grid-template-columns: repeat(2,1fr); /* remove if not display:grid */
width: max-content;
padding: 1em;
right:0;
margin-right:calc(0px - 10vw);
}
}
@wpgaurav
wpgaurav / 2-backend-css.php
Last active August 23, 2022 07:47
Making Marketers Delight 100% Gutenberg ready
<?php
add_action(
'enqueue_block_editor_assets',
function () {
$theme = wp_get_theme();
wp_enqueue_style(
'block-md-custom-css', '/wp-content/themes/md-child/custom-editor.css?v=1'
);
}
);