Skip to content

Instantly share code, notes, and snippets.

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

Gulshan Kumar thegulshankumar

🏠
Working from home
View GitHub Profile
@thegulshankumar
thegulshankumar / Exclude Posts from Any Specific Category from RSS Feed
Created February 28, 2025 04:30
Exclude Posts from Any Specific Category from RSS Feed in WordPress
/**
* Exclude Posts from Any Specific Category from RSS Feed in WordPress
*
* Use Case:
* This function is designed for a scenario where you manage a website that publishes content
* across ten different categories, but one specific category contains sensitive or restricted content.
* To comply with your content distribution policy, you may wish to exclude that particular category
* from appearing in the RSS feed.
*
* Solution:
@thegulshankumar
thegulshankumar / Enhancing Dashboard User Experience for Contributors and Non-Admins.php
Last active February 3, 2025 10:54
Enhancing Dashboard User Experience for Contributors and Non-Admins
<?php
/**
* By default, users with the Contributor role cannot upload images.
* The following snippet overrides this restriction, allowing them to upload images.
*/
function allow_contributor_uploads() {
$role = get_role( 'contributor' );
@thegulshankumar
thegulshankumar / Web Stories archive.css
Created December 31, 2024 09:12
A better style for the Web Stories archive
<style>
.separate-containers .page-header {
border: none;
margin-left: 15px;
}
/* Main container styles */
.post-type-archive-web-story .site-main {
display: flex;
flex-wrap: wrap;
justify-content: center; /* Centers the stories */
@thegulshankumar
thegulshankumar / enable_feedify_checkbox.php
Last active August 22, 2024 10:58
Checkbox Enabler for Feedify Push Notifications System
<?php // Skip this line, beautification only. Start copying from Line #2.
function add_feedify_checkbox_enabler() {
?>
<script type="text/javascript">
(function($) {
$(document).ready(function() {
function enableFeedifyCheckbox() {
var checkbox = $('#s_f_noti');
if (checkbox.length) {
checkbox.prop('disabled', false).prop('checked', true);
@thegulshankumar
thegulshankumar / remove-date-time-from-gp-theme.php
Created May 2, 2024 08:54
Remove Date & Time in GeneratePress Comment section
<?php // Place this snippet in the functions.php file or use the Code Snippets plugin without PHP opening tags
/*
* Concepts behind the solution
* Google says: If you've followed the best practices above
* and find incorrect dates are being selected,
* consider if you can remove or minimize other dates that may appear on the page.
* https://developers.google.com/search/blog/2019/03/help-google-search-know-best-date-for
*
* Note: It worked for us.
@thegulshankumar
thegulshankumar / Restoring Category Assignments: Reconnecting Posts with their Category.php
Created April 30, 2024 14:02
Restoring Category Assignments: Reconnecting Posts with their Category
<?php
/*
Yikes! I deleted a category in WordPress by mistake. Now what?
Well, if you have an old backup, you can extract the list of Post IDs from that specific category.
This is an alternative approach to restoring the entire backup.
Let's say the category name was 'College & Admission' with the slug 'college-admission'.
@thegulshankumar
thegulshankumar / smart-404.html
Created April 20, 2024 16:13
Smart-404.html for Redirecting Deprecated Translated Pages to English Version 🚀
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>example.com</title>
<style>
body, html {
height: 100%;
margin: 0;
<?php
/**
* Special condition: If your WordPress has a settings to automatically approve all comments without a manual approval
* In this case, Cloudflare plugin may not purge the cache.
* This is a quick-workaround. After adding this snippet,
* you need to create a rule to bypass the Cache for comment-posted=true query string
*/
add_filter( 'comment_post_redirect', 'redirect_after_comment' );
function redirect_after_comment( $location ) {
@thegulshankumar
thegulshankumar / Flush DNS Cache
Created August 26, 2023 05:00
Flush DNS Cache
Google Public DNS (8.8.8.8, 8.8.4.4)
https://dns.google/cache
Cloudflare DNS (1.1.1.1, 1.0.0.1)
https://1.1.1.1/purge-cache/
OpenDNS (208.67.222.222, 208.67.220.220)
@thegulshankumar
thegulshankumar / Display a Quick Summary for the News Article.php
Last active August 4, 2023 14:10
Display a Quick Summary for the News Article
/**
* News Summary: Display the most important information first.
*
* This code snippet adds a custom meta box called "News Summary" in the Post editor.
* The meta box allows users to input a summary for each post, which will be displayed
* at the beginning of the post's content on the single post page.
*/
// Register the Summary Meta Box
function custom_news_summary_meta_box() {