Skip to content

Instantly share code, notes, and snippets.

View Bobz-zg's full-sized avatar
👨‍💻
working remotely

Vlado Bosnjak Bobz-zg

👨‍💻
working remotely
View GitHub Profile
@Bobz-zg
Bobz-zg / functions.php
Last active January 17, 2023 20:30
Filter WordPress posts by custom taxonomy term with AJAX
<?php
/**
* AJAC filter posts by taxonomy term
*/
function vb_filter_posts() {
if( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'bobz' ) )
die('Permission denied');
/**
@Bobz-zg
Bobz-zg / wp-ajax-filter-posts-by-tag.php
Created August 12, 2016 16:06
Filter WP posts by tag - PHP
<?php
/**
* Enqueue JS file
* Be sure to update path to js
*
* @link https://gist.github.com/Bobz-zg/16578c3c173abfe2b22daffd67f6f1e0
*
*/
function ajax_filter_posts_scripts() {
@Bobz-zg
Bobz-zg / wp-ajax-filter-posts-by-tag.js
Created August 12, 2016 16:03
Filter WP posts by tag - JS
jQuery(document).ready(function($) {
$('.tax-filter').click( function(event) {
// Prevent default action - opening tag page
if (event.preventDefault) {
event.preventDefault();
} else {
event.returnValue = false;
}
@Bobz-zg
Bobz-zg / redirect-wp-post.php
Last active April 12, 2023 09:37
Redirects wordpress posts to new url: site.com/blog/post-name
<?php
/**
* Add new rewrite rule
*/
function create_new_url_querystring() {
add_rewrite_rule(
'blog/([^/]*)$',
'index.php?name=$matches[1]',
'top'
);
@Bobz-zg
Bobz-zg / SassMeister-input.scss
Created February 25, 2016 04:16
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
$icons-svg: (
sprite: (width: 132px, height: 88px, svgPath: '../images/sprite.svg'),
facebook: (width: 33.9px, height: 33.9px, backgroundX: 0px, backgroundY: 0px),
linkedin: (width: 33.9px, height: 33.9px, backgroundX: -43.9px, backgroundY: 0px),
pinterest: (width: 33.9px, height: 33.9px, backgroundX: 0px, backgroundY: -43.9px),
twitter: (width: 33.9px, height: 33.9px, backgroundX: -43.9px, backgroundY: -43.9px),
@Bobz-zg
Bobz-zg / SassMeister-input.scss
Created February 25, 2016 04:13
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
$icons-svg: (
sprite: (width: 132px, height: 88px, svgPath: '../images/sprite.svg'),
facebook: (width: 33.9px, height: 33.9px, backgroundX: 0px, backgroundY: 0px),
linkedin: (width: 33.9px, height: 33.9px, backgroundX: -43.9px, backgroundY: 0px),
pinterest: (width: 33.9px, height: 33.9px, backgroundX: 0px, backgroundY: -43.9px),
twitter: (width: 33.9px, height: 33.9px, backgroundX: -43.9px, backgroundY: -43.9px),
@Bobz-zg
Bobz-zg / Populate ACF Select field choices with Gravity Forms
Last active November 7, 2015 07:40
Populate ACF Select field choices with Gravity Forms
function vb_acf_load_gforms( $field ) {
global $wpdb;
$sql = "SELECT * FROM {$wpdb->prefix}rg_form";
$forms = $wpdb->get_results( $sql );
$field['choices'] = array();
if( $forms ) :
@Bobz-zg
Bobz-zg / Roots 7.0.0.-main.scss
Created July 22, 2014 14:00
Main.scss file for Roots 7.0.0. using SASS + Compass
@import "compass";
// Core variables and mixins
@import "../vendor/bootstrap-sass/lib/variables";
@import "../vendor/bootstrap-sass/lib/mixins";
// Reset
@import "../vendor/bootstrap-sass/lib/normalize";
@import "../vendor/bootstrap-sass/lib/print";
@Bobz-zg
Bobz-zg / Roots 7.0.0.-config
Created July 22, 2014 13:51
Config.rb file for Roots 7.0.0. using SASS + Compass
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "assets/css"
sass_dir = "assets/sass"
images_dir = "assets/img"
javascripts_dir = "assets/js"
fonts_dir = "assets/fonts"
output_style = :expanded
@Bobz-zg
Bobz-zg / Roots 7.0.0.-package
Created July 22, 2014 13:49
package.json file for Roots 7.0.0. using SASS + Compass
{
"name": "roots",
"version": "7.0.0",
"author": "Ben Word <ben@benword.com>",
"homepage": "http://roots.io",
"repository": {
"type": "git",
"url": "git://github.com/roots/roots.git"
},
"bugs": {