Skip to content

Instantly share code, notes, and snippets.

View bicho44's full-sized avatar

Federico Reinoso bicho44

View GitHub Profile
@lukecav
lukecav / Links
Last active June 14, 2021 02:05
Speed Up Your WordPress Site with These 3 Advanced Techniques Workshop - WordSesh 2021
@tdmrhn
tdmrhn / blocksy-product-filter.php
Created May 25, 2021 23:52
Blocksy Products live jQuery filter
<script>
jQuery(document).ready(function($) {
$('.ct-filter').on( 'click', function(event){
var $type = $(this).data("filter");
if($type == "all"){
$('.type-product').fadeOut(0);
$('.type-product').fadeIn(500);
} else {
$('.type-product').hide();
// For CPTs just change the category class to your CPTs slug for example: '.projects-'
@tdmrhn
tdmrhn / blocksy-blog-filter.php
Last active April 29, 2023 11:26
Blocksy Blog or CPT live jQuery filter
<script>
jQuery(document).ready(function($) {
$('.ct-filter').on( 'click', function(event){
var $type = $(this).data("filter");
if($type == "all"){
$('.entry-card').fadeOut(0);
$('.entry-card').fadeIn(500);
} else {
$('.entry-card').hide();
// For CPTs just change the category class to your CPTs slug for example: '.projects-'
@Shelob9
Shelob9 / reorder-cpt-archive.php
Created February 5, 2014 21:25
Reorder a WordPress custom post type archive page by the value of a meta field. Based on this SE answer: http://wordpress.stackexchange.com/a/48658/25300
<?php
function slug_order_archive_by_field( $query ) {
//Only do if is main query fo a specific cpt's archive.
//@TODO set cpt's name
if ( $query->is_main_query() && is_post_type_archive( 'CPT_NAME' ) ) {
//@TODO Set the name of the field we are ordering by
$query->set( 'meta_key', 'FIELD_NAME' );
//@TODO change order to DESC IF you want to go in reverse order
$query->set( 'order', 'ASC' );
//@TODO uncomment next line IF you want to sort by an integer instead of alphabetically
@ebinnion
ebinnion / bootstrap_wp_link_pages.php
Last active March 14, 2017 10:02
Extends the WordPress wp_link_pages function in order to style the page links with Bootstrap's classes.
@justintadlock
justintadlock / register-post-type.php
Last active October 22, 2023 05:55
Help file when registering post types.
<?php
# Register custom post types on the 'init' hook.
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 1.0.0
* @access public
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active April 2, 2024 02:45
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@media only screen and (min-width: 320px) {
/* Small screen, non-retina */
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 320px),
@clarklab
clarklab / wp_insert_post_front_end_form.php
Created May 25, 2012 00:12
This is a sample front-end form using wp_insert_post(). It's quickly stripped out of my production code from Android and Me, and hasn't been tested alone, so please take it with a grain of salt.
<?
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['insert_post'] )) { //check that our form was submitted
$title = $_POST['thread_title']; //set our title
if ($_POST['thread_description']=="") { // check if a description was entered
$description = "See thread title..."; // if not, use placeholder
} else {
$description = $_POST['thread_description']; //if so, use it
@bicho44
bicho44 / blackandwhiteimages.php
Created April 19, 2012 22:17
Generate B + W images in WordPress
<?php
add_image_size('thumbnail-bw', 400, 0, false);
add_filter('wp_generate_attachment_metadata','bw_images_filter');
function bw_images_filter($meta) {
$file = wp_upload_dir();
$file = trailingslashit($file['path']).$meta['sizes']['thumbnail-bw']['file'];
list($orig_w, $orig_h, $orig_type) = @getimagesize($file);
$image = wp_load_image($file);
imagefilter($image, IMG_FILTER_GRAYSCALE);