Skip to content

Instantly share code, notes, and snippets.

View goranseric's full-sized avatar

Goran Šerić goranseric

View GitHub Profile
<html>
<head>
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
</head>
<body>
<div id="map" style="height: 400px; width: 500px;">
</div>
<script type="text/javascript">
@goranseric
goranseric / acf-get-field-key.php
Created September 12, 2018 18:18 — forked from mcguffin/acf-get-field-key.php
WordPress Advanced Custom Fields get field key from field name
<?php
/**
* Get field key for field name.
* Will return first matched acf field key for a give field name.
*
* ACF somehow requires a field key, where a sane developer would prefer a human readable field name.
* http://www.advancedcustomfields.com/resources/update_field/#field_key-vs%20field_name
*
* This function will return the field_key of a certain field.
@goranseric
goranseric / main.js
Created September 9, 2018 17:21 — forked from Bobz-zg/main.js
Filter WordPress posts by custom taxonomy term with AJAX - Javscript
(function($) {
$doc = $(document);
$doc.ready( function() {
/**
* Retrieve posts
*/
function get_posts($params) {
@goranseric
goranseric / shortcode.php
Created September 9, 2018 17:21 — forked from Bobz-zg/shortcode.php
Filter WordPress posts by custom taxonomy term with AJAX
<?php
/**
* Shortocde for displaying terms filter and results on page
*/
function vb_filter_posts_sc($atts) {
$a = shortcode_atts( array(
'tax' => 'post_tag', // Taxonomy
'terms' => false, // Get specific taxonomy terms only
'active' => false, // Set active term by ID
@goranseric
goranseric / functions.php
Created September 9, 2018 17:21 — forked from Bobz-zg/functions.php
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');
/**
<?php
/**
* My Project
*
* @package MyProject
* @subpackage JesGs_Walker_Category
* @author Jess Green <jgreen@psy-dreamer.com>
* @version $Id$
*/
<?php if (($wp_query->current_post +1) == ($wp_query->post_count)) {
echo 'This is the last post';
} ?>
<?php if (($wp_query->current_post +1) != ($wp_query->post_count)) {
echo 'This is the not the last post';
} ?>
@goranseric
goranseric / csv_to_array.php
Created August 30, 2018 10:29 — forked from jaywilliams/csv_to_array.php
Convert a comma separated file into an associated array.
<?php
/**
* Convert a comma separated file into an associated array.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
* @return array
@goranseric
goranseric / mu-fSelect.js
Created August 30, 2018 05:51 — forked from ffoodd/mu-fSelect.js
FacetWP accessibility improvements
(function($) {
$.fn.fSelect = function(options) {
if ('string' === typeof options) {
var settings = options;
}
else {
var settings = $.extend({
placeholder: 'Select some options',
@goranseric
goranseric / acf-set-field-name.php
Created August 29, 2018 12:04 — forked from solepixel/acf-set-field-name.php
Differentiate Settings Page fields when using the same field groups. Requires "menu_slug" prefixed with something common and identifiable, in this case the Post Type of the Archive as well as a common naming convention, in this example it uses "-archive-settings".
<?php
add_filter( 'acf/load_field', 'mytheme_set_field_name' );
function mytheme_set_field_name( $field ){
if( is_admin() ){
$screen = get_current_screen();
if( $screen->id == 'acf-field-group' )
return $field;