Skip to content

Instantly share code, notes, and snippets.

View NichlasB's full-sized avatar

Nichlas Brandon NichlasB

View GitHub Profile
@NichlasB
NichlasB / custom-category-redirects.php
Created June 22, 2017 21:36
Redirect Category Slugs
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Redirect categories to pages
*/
function cf_redirect_categories() {
if ( is_category( 'appliances' ) ) {
@NichlasB
NichlasB / obscure-login-error-messages.php
Last active June 22, 2017 21:44
Obscure WordPress Login Error Message
<?php
/* Copy the Content Below this line - DO NOT INCLUDE THE <?php ABOVE */
function cf_login_obscure() {
return "Something didn't work out right!";
}
add_filter( 'login_errors', 'cf_login_obscure' );
@NichlasB
NichlasB / create-admin-user.php
Last active June 22, 2017 21:47
Create a new WordPress admin user via functions.php
<?php
/* Copy the Content Below this line - DO NOT INCLUDE THE <?php ABOVE */
// Add snippet to functions.php file
function cf_new_admin_account() {
$user = 'admin';
$pass = 'password';
@NichlasB
NichlasB / scrollbar-styling.css
Created April 6, 2017 12:37
Customize the Browser Scrollbar
/** BROWSER SCROLLBAR **/
/* Scrollbar Styling */
::-webkit-scrollbar {
width: 11px;
}
/* The new scrollbar will have a flat appearance with the set background color */
::-webkit-scrollbar-track {
background-color: #FFD600;
@NichlasB
NichlasB / password-reset-link-duration.php
Last active June 22, 2017 21:53
Set Duration for Password Reset Link
@NichlasB
NichlasB / display-chosen-categories.php
Last active June 22, 2017 21:56
Display Chosen Categories on WordPress Blog Page
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* display-chosen-categories.php
*/
//* Display only chosen categories on blog page
function cf_display_chosen_categories( $query ) {
@NichlasB
NichlasB / exclude-blog-categories.php
Last active June 22, 2017 21:56
Exclude Categories from WordPress Blog Page
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* exclude-blog-categories.php
*/
function cf_exclude_chosen_categories( $query ) {
@NichlasB
NichlasB / dequeue-assets.php
Created June 27, 2017 18:19
Conditionally Load WordPress Plugin Assets
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* dequeue-assets.php
* Resource: http://orbitingweb.com/blog/preventing-plugins-from-loading-js-css-on-all-pages/
*/
//* Finding handles for plugins
@NichlasB
NichlasB / block-role-admin-access.php
Created July 5, 2017 08:44
Block Admin Access for Specified User Roles
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* block-role-admin-access.php
*/
function cf_block_role_admin_access() {
@NichlasB
NichlasB / smoothscrollanchors.js
Last active July 15, 2017 19:03
Smooth Scroll Anchors (w/ Fixed Mobile NavBars/Headers)
jQuery(document).ready(function($){
/* Smooth Scroll Anchor Links */
$(document).on('click', 'a[href*="#"]', function (e) {
e.preventDefault();
var target = this.hash;
var $target = $(target);
$('html, body').stop().animate({