Skip to content

Instantly share code, notes, and snippets.

@WaseemMansour
WaseemMansour / inc\helpers\single-related-posts.php
Last active January 3, 2025 17:24
Related Posts Without Plugins
@hearvox
hearvox / wp-top-parent-body-class.php
Last active February 23, 2023 16:22
Add class name for top-level parent category or page to body tag in WordPress posts, pages, and archives.
<?php
/**
* Insert class into body tag for highest level Category or Page.
*
* Pages and Categories with identical slugs get the same class.
* Works on Pages, Posts, and Category achives.
*
* @return string $top_slug Class name for body tag.
*/
function top_cat_or_page_body_class( $class ) {
@ethanpil
ethanpil / wp-secure.conf
Created May 12, 2017 16:16
Wordpress Security for NginX
# wp-secure.conf
#
#
# This file includes common security considerations for wordpress using nginx.
#
# The goal is to block actions which are usually dangerous to wordpress.
# Additionally, we block direct access to PHP files and folders which should not
# be accessed directly from a browser.
#
# Also have included exceptions for plugins that are known to require this access.
@tabrindle
tabrindle / webp-convert-directory.sh
Last active April 16, 2025 15:25
Convert all files in directory to webp, with default params, or standard cwebp params passed from command
#!/bin/bash
PARAMS=('-m 6 -q 70 -mt -af -progress')
if [ $# -ne 0 ]; then
PARAMS=$@;
fi
cd $(pwd)
@loorlab
loorlab / wp-cheat-sheet
Created October 20, 2015 07:28
Wordpress cheat sheets
1. Theme Structure
- style file
style.css
- header section
header.php
- main section
index.php