Skip to content

Instantly share code, notes, and snippets.

View wpgaurav's full-sized avatar
👋
Hello!

Gaurav Tiwari wpgaurav

👋
Hello!
View GitHub Profile
<?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 / functions.php
Created May 10, 2020 16:10 — forked from grtaylor2/functions.php
How to Add a Login/Logout Link to Your WordPress Genesis
<?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>';
@wpgaurav
wpgaurav / dont-make-comment-hyperlink-clickable.php
Created September 7, 2020 08:28
Don’t Make Comment Hyperlinks automatically clickable.
@wpgaurav
wpgaurav / disable-wpcomtoolbar.php
Created October 16, 2020 09:09
Disable WordPress.com Toolbar in WordPress.com Business and Ecommerce Plans
<?php
function disable_wpcomtoolbar ( $modules ) {
if ( isset( $modules['masterbar'] ) ) {
unset( $modules['masterbar'] );
}
return $modules;
}
add_filter( 'jetpack_get_available_modules', 'disable_wpcomtoolbar' );
?>
@wpgaurav
wpgaurav / Mdhooks.php
Last active October 16, 2020 09:12
Marketers Delight Hooks
<?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 / list-child-pages.php
Created October 16, 2020 09:17
List Child Pages or Subpages of a Page in the page with [gt_childpages] shortcode
<?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 / header-triggers.php
Created November 16, 2020 06:14
Custom Trigger with AMP
<?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-style.css
Last active November 28, 2020 04:08
List Style for Bablu Yadav
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 / custom-editor.css
Last active February 10, 2021 15:46
Gutenberg Extra CSS for MD
/* @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 / star-rating.html
Created February 26, 2021 02:23
Star rating schema - Add this code to anywhere on the page
<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"
}