Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Gaurav Tiwari wpgaurav

🎯
Focusing
View GitHub Profile
@wpgaurav
wpgaurav / star-rating.html
Created Feb 26, 2021
Star rating schema - Add this code to anywhere on the page
View star-rating.html
<script type="application/ld+json">{
"@context": "https://schema.org/",
"@type": "CreativeWorkSeries",
"name": "YOUR POST TITLE HERE",
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4.8",
"bestRating": "5",
"ratingCount": "3694"
}
@wpgaurav
wpgaurav / custom-editor.css
Last active Feb 10, 2021
Gutenberg Extra CSS for MD
View custom-editor.css
/* @import url('https://fonts.googleapis.com/css2?family=Source+Sans+Pro:ital,wght@0,400;0,600;0,700;1,400;1,600;1,700&display=swap'); */
h3.numbered {
counter-reset: h4;
counter-increment: h3;
}
h2.numbered {
counter-reset: h3;
counter-increment: h2;
}
h3.numbered::before {
@wpgaurav
wpgaurav / list-style.css
Last active Nov 28, 2020
List Style for Bablu Yadav
View list-style.css
article ol li {
list-style:none;
padding:10px 20px;
border-bottom:1px solid #ddd
}
article ol {
counter-reset:rowNumber;
padding:0!important;
background: white;
border: 1px solid #ddd;
@wpgaurav
wpgaurav / header-triggers.php
Created Nov 16, 2020
Custom Trigger with AMP
View header-triggers.php
<?php if ( md_has_menu() ) : ?>
<span id="header-menu-trigger" on="tap:sidebar.toggle" class="header-menu-trigger header-trigger"></span>
<?php endif; ?>
@wpgaurav
wpgaurav / list-child-pages.php
Created Oct 16, 2020
List Child Pages or Subpages of a Page in the page with [gt_childpages] shortcode
View list-child-pages.php
<?php
function gt_list_child_pages() {
global $post;
if ( is_page() && $post->post_parent )
$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' );
else
$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' );
@wpgaurav
wpgaurav / Mdhooks.php
Last active Oct 16, 2020
Marketers Delight Hooks
View Mdhooks.php
<?php
// Display Custom Excerpt below the headline on single posts.
function excerpt_single_post() {
if ( is_singular( 'post' ) && has_excerpt() ) {
the_excerpt();
}
}
add_action ('md_hook_after_headline', 'excerpt_single_post');
?>
@wpgaurav
wpgaurav / disable-wpcomtoolbar.php
Created Oct 16, 2020
Disable WordPress.com Toolbar in WordPress.com Business and Ecommerce Plans
View disable-wpcomtoolbar.php
<?php
function disable_wpcomtoolbar ( $modules ) {
if ( isset( $modules['masterbar'] ) ) {
unset( $modules['masterbar'] );
}
return $modules;
}
add_filter( 'jetpack_get_available_modules', 'disable_wpcomtoolbar' );
?>
@wpgaurav
wpgaurav / dont-make-comment-hyperlink-clickable.php
Created Sep 7, 2020
Don’t Make Comment Hyperlinks automatically clickable.
View dont-make-comment-hyperlink-clickable.php
@wpgaurav
wpgaurav / functions.php
Created May 10, 2020 — forked from grtaylor2/functions.php
How to Add a Login/Logout Link to Your WordPress Genesis
View functions.php
<?php // add everything except for this opening line to your functions file
add_filter( 'wp_nav_menu_items', 'sp_add_loginout_link', 10, 2 );
function sp_add_loginout_link( $items, $args ) {
// Change 'primary' to 'secondary' to put the login link in your secondary nav bar
if ( $args->theme_location != 'primary' )
return $items;
if ( is_user_logged_in() ) {
$items .= '<li class="menu-item"><a href="'. wp_logout_url() .'">Log Out</a></li>';
} else {
$items .= '<li class="menu-item"><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
View display-subpages.php
<?php function gt_list_child_pages() {
global $post;
if ( is_page() && $post->post_parent )
$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' );
else
$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' );