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
@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 / 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;
}
$('#first').animate({
height: $('#first').get(0).scrollHeight
}, 1000, function(){
$(this).height('auto');
});
@ashsaraga
ashsaraga / if_custom_page_field_equals.html
Last active August 27, 2021 16:25
Example with custom page field "Background Image."
{% ifequal page.custom_fields.signup_background_image 'bg.jpg' %}
{% else %}
{% endifequal %}
function pinElement() {
var trigger = $('.trigger').offset().top;
$(window).scroll(function(){
if($(window).scrollTop() > (trigger)){
// function after trigger
} else {
// function before trigger
}
});
}
<?php
// get date meta as string
$meta_date = get_post_meta( $post->ID, '_meta_date', true );
// store date meta as date data type
$meta_datetime = strtotime( $meta_date );
// store date meta as "Month day, year"
$meta_datetext = date( 'F j, Y', $meta_datetime );
<?php
$meta_value = esc_html( get_the_title() ); // set $meta_value to query for
$args = array(
'meta_query' => array(
'relation' => 'OR', // retrieve post if either query is true
'meta_subquery1' => array(
'key' => 'meta_key1',
'value' => $meta_value,
'compare' => '='
),
<?php
// Move Yoast SEO to the bottom of the page editor
function yoasttobottom() {
return 'low';
}
add_filter( 'wpseo_metabox_prio', 'yoasttobottom');
<?php
function remove_menus() {
remove_menu_page( 'index.php' ); // Dashboard
remove_menu_page( 'edit.php' ); // Posts
remove_menu_page( 'edit-comments.php' ); // Comments
remove_menu_page( 'themes.php' ); // Appearance
remove_menu_page( 'plugins.php' ); // Plugins
remove_menu_page( 'users.php' ); // Users
remove_menu_page( 'tools.php' ); // Tools
remove_menu_page( 'options-general.php' ); // Settings
<?php
echo post_type_archive_title( '', false );