Skip to content

Instantly share code, notes, and snippets.

View ashsaraga's full-sized avatar
🌈
Building tools only I'll wind up using.

Ash Saraga ashsaraga

🌈
Building tools only I'll wind up using.
View GitHub Profile
$('#first').animate({
height: $('#first').get(0).scrollHeight
}, 1000, function(){
$(this).height('auto');
});
@ashsaraga
ashsaraga / login-styles.css
Last active March 2, 2018 22:25
Customize the WordPress login screen background, inputs and logo.
/*
* Styles for Custom Login page
*/
body.login {
background-image: url('background.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
@ashsaraga
ashsaraga / teatime.js
Created March 16, 2018 04:46
Toggle focus on target element, get value from input.
$(document).ready(function() {
whiteRabbit();
madHatter();
marchHare();
function whiteRabbit() {
var stopwatch;
drinkMe();
}
@ashsaraga
ashsaraga / getParams.js
Created April 13, 2018 18:17
Will set the value for any input with a name attribute equal to a URL parameter key.
function setParams() {
// Sets the value of any field with a matching name attribute
var params;
params = getParams();
$.each( params, function( key, value ) {
var ref;
ref = $('input[name="'+key+'"');
if (ref.length) {
$(ref).val(value);
}
@ashsaraga
ashsaraga / custom_tax.php
Created May 14, 2018 19:23
Custom taxonomies in WordPress.
/**
* Add custom taxonomies
*
* Additional custom taxonomies can be defined here
* http://codex.wordpress.org/Function_Reference/register_taxonomy
*/
function add_custom_taxonomies() {
// Add new "Locations" taxonomy to Posts
register_taxonomy('location', 'post', array(
// Hierarchical taxonomy (like categories)
<?php
// Echo with lowercase first letter
echo lcfirst( post_type_archive_title( '', false ) );
// Echo as titled in WP
echo post_type_archive_title( '', false );
?>
@ashsaraga
ashsaraga / setURL.php
Created May 31, 2018 20:17
Include in `wp-config.php` to set the URL for a WordPress install.
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
@ashsaraga
ashsaraga / wpSSL.conf
Created May 31, 2018 20:23
Include in the site's `-le-ssl.conf` file to avoid redirect loop on HTTPS request.
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://example.com%{REQUEST_URI} [END,NE,R=permanent]
@ashsaraga
ashsaraga / sort_bymeta.php
Last active August 27, 2021 16:25
Sorts any archive by any meta field.
<?php
$the_key = ''; // Field Name to sort on
$args = array( 'meta_key' => $the_key,
'orderby' => 'meta_value',
'order' => 'ASC'
);
global $wp_query;
query_posts(
array_merge(
$wp_query->query,