Skip to content

Instantly share code, notes, and snippets.

View cparkinson's full-sized avatar

Clare Parkinson cparkinson

View GitHub Profile
@cparkinson
cparkinson / facetwp-location-indexer.js
Created September 8, 2022 20:40
FacetWP when indexing all posts, create an index row for a particular term
/**
*
* When indexing, for every post, for the location filter,
* Check to see if it has any location taxonomy set
* Check to see if selected location taxonomy has children (i.e. selected county has cities)
* Create a new index row for each child city
*
* So that Admin Panel editors can check only county for content
* But front-end users will be able to type city into autocomplete and find parent county content
*/
@cparkinson
cparkinson / wp-exclude-category-from-postmeta.php
Created October 7, 2020 22:00
wp exclude category from postmeta
/**
* hide 'for parents' and 'featured' categories in list of cats in post's postmeta
*/
function ca_response_exclude_category_from_postmeta( $categories ) {
$exclude = array( 'featured','for-parents' );
foreach ( $categories as $index => $category ){
if ( in_array( $category->slug, $exclude ) ){
unset( $categories[ $index ] );
}
}
@cparkinson
cparkinson / uag-post-grid-show-all-categories
Last active October 28, 2022 17:36
uag post grid show all categories
/**
*
* UAG Post Grid block displays one category for each post
* filter to display all categories,
* original display remains in block - has to be hidden with CSS
*/
function ca_response_single_post_meta_before_meta_grid( $post_id, $attributes ) {
//copied from astra/inc/blog/blog-config.php : astra_get_post_meta
global $post;
@cparkinson
cparkinson / divi-adding-header-height-spacing.js
Created July 22, 2020 14:52
Nancy Mikyska's snippet for fixing Divi header height
<script>
jQuery(document).ready(function(){
var totalheight = 0;
jQuery(".et-l--header .et_builder_inner_content .et_pb_section").each(function(){
totalheight = totalheight + jQuery(this).outerHeight();
});
totalheight = totalheight + "px";
jQuery("#et-main-area").css("padding-top",totalheight);
});
</script>
@cparkinson
cparkinson / facetwp-index-all-posts-demo.php
Created May 13, 2020 16:29
FacetWP - index all posts demo
/**
* Filter to customize FacetWP, should be pasted in FacetWP's "Custom Hooks" plugin
*
* Made as a demo so I could figure out how FacetWP index filter works.
* gives every post an entry in the "location_filter" facet
*
*/
add_filter( 'facetwp_indexer_row_data', function( $rows, $params ) {
if ( 'location_filter' == $params['facet']['name'] ) {
@cparkinson
cparkinson / facetwp-autoindex-child-terms.php
Created May 13, 2020 16:22
FacetWP - automatically index all child terms when a parent taxonomy term is checked
/**
* Filter to customize FacetWP, should be pasted in FacetWP's "Custom Hooks" plugin
*
* Made for a "location" FacetWP autocomplete filter that uses a taxonomy "location"
* consisting of parent county terms and child city terms
*
* When indexing, for every post, for the location taxonomy filter,
* Check to see if it has any location taxonomy set
* Check to see if selected location taxonomy has children (i.e. selected county has cities)
* Create a new index row for each child city
@cparkinson
cparkinson / page-taxonomy-report.php
Created February 8, 2019 16:04
Taxonomy report page template
<?php
/*
Not intended for display!
This page template generates a list of all categories and all tags. Will display for pages titled "taxonomy report"
Set page to Private and send clients the link so they can see their taxonomy
Author: Clare
January 2019
*/
get_header(); ?>
<?php if ( have_posts() ) : ?>
@cparkinson
cparkinson / gist:2ac2555d51bed703ce2d39e14d1de699
Created May 8, 2018 19:10
Order posts in a certain category by date ASC
/*
For when there's a category of team bios.
If you create them up in alphabetical order,
then the reverse date order will retain that order
This goes in functions.php
*/
/*Order bio Posts in reverse date order, set limit at 30 posts */
function prefix_modify_query_order( $query ) {
@cparkinson
cparkinson / download-member-report.php
Last active September 5, 2017 17:22
FacetWP template for generating csv of result set
<?php
/*
/*
Plugin Name: Download member report as csv
Plugin URI: http://
Description: This plugin is called when the 'download csv' button is clicked on the Member Reports page containing FacetWP search
Version: 1.0
Author: clare@greenbee-web.com
Author URI: http://www.greenbee-web.com/
License: GPL2
@cparkinson
cparkinson / custom_field_for_store_setting
Created August 26, 2016 17:24
Code to add custom usermeta field to WC Vendors Pro store settings page
/* this is in themes functions.php*/
/******product page blurb***********/
function kindeye_store_product_page_blurb(){
if ( class_exists( 'WCVendors_Pro' ) ){
$key = '_wcv_product_page_vendor_blurb';
$value = get_user_meta( get_current_user_id(), $key, true );
// Product Page blurb
WCVendors_Pro_Form_Helper::input( array(
'id' => $key,