Skip to content

Instantly share code, notes, and snippets.

@simplistik
simplistik / functions.php
Last active April 2, 2024 15:45
Fetch WP "posts" in chunks.
<?php
/**
* Fetch posts in chunks.
*
* This function fetches posts in chunks of a specified size, which can be useful for large datasets.
*
* @param string $post_type The type of post to fetch. Default is 'post'.
* @param int $posts_per_page The number of posts to fetch per page. Default is 100.
* @param array $custom_args Custom arguments to pass to WP_Query. Default is an empty array.
*
@bahiirwa
bahiirwa / webpack.config.js
Created March 26, 2023 15:24
Multiple entry points for webpack.config.js using @wordpress/scripts
// Set from https://www.npmjs.com/package/@wordpress/scripts
// Add package.json with the @wordpress/scripts dependency.
// Add a root file called webpack.config.js
// Import the original config from the @wordpress/scripts package.
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
// Import the helper to find and generate the entry points in the src directory
const { getWebpackEntryPoints } = require( '@wordpress/scripts/utils/config' );
@chrismademe
chrismademe / data.php
Created July 25, 2019 15:25
get-post-with-fields.php
/**
* Get Post with Fields
*
* Returns a post with it's ACF fields
* attached to it
*
* @NOTE We don't use $post as a variable
* inside here so we don't mess with the
* WordPress global variable
*
@jchristopher
jchristopher / functions.php
Last active December 18, 2020 12:49
Tell SearchWP 3.x to index the Title from a Relationship ACF field
<?php
/**
* SearchWP VERSION 3.x
* Tell SearchWP to index the Title from a Relationship ACF field.
*/
function my_searchwp_read_next_field( $meta_value, $meta_key, $the_post ) {
$acf_field_name = 'read_next'; // The ACF Relationship field name.
// If we're not indexing the Read Next field, return the existing meta value.
@Garconis
Garconis / acf-states.txt
Created August 10, 2018 16:21 — forked from michaeldozark/acf-states.txt
State list for Advanced Custom Fields select field
AL : Alabama
AK : Alaska
AZ : Arizona
AR : Arkansas
CA : California
CO : Colorado
CT : Connecticut
DE : Delaware
DC : District of Columbia
FL : Florida
@felipefernandes
felipefernandes / bitbucket-pipelines.yml
Last active February 10, 2021 16:14
Bitbucket pipeline for ftp deployment ( Node + Gulp + Bower + FTP + Rsync )
image: node:6.11.2
pipelines:
custom: # Pipelines that are triggered manually
deployment-to-production-init:
- step:
caches:
- node
script: # Modify the commands below to build your repository.
- npm install -g gulp
@khromov
khromov / acf-nowhere-location-rule.php
Created October 2, 2017 17:36
"Nowhere" location rule for Advanced Custom Fields - never matches
<?php
/*
Plugin Name: Advanced Custom Fields: Nowhere location rules
Description: Adds a "Nowhere" location rule in ACF
*/
add_filter('acf/location/rule_types', function($rules) {
$rules['Extra']['nowhere'] = 'Nowhere';
@mgibbs189
mgibbs189 / functions.php
Last active August 27, 2020 13:20
Add submit button after search input
<?php
add_action( 'wp_head', function() {
?>
<script>(function($) {
$(document).on('facetwp-loaded', function() {
$('.facetwp-input-wrap').each(function() {
if ($(this).find('.facetwp-search-submit').length < 1) {
$(this).find('.facetwp-search').after('<button class="facetwp-search-submit" onclick="FWP.refresh()">Submit</button>');
}
@alex-boom
alex-boom / Mixin-rem-calc.scss
Last active June 14, 2021 15:08
Mixin-rem-calc
/// Mixin rem-calc for converting px units into rem units
/// @example scss - Usage
/// .element {
/// font-size: rem-calc(20);
/// }
///
/// @example css - CSS Output
/// .element {
/// font-size: 1.25rem;
/// }
@mgibbs189
mgibbs189 / custom-loop.php
Last active September 1, 2022 13:25 — forked from SauntValerian/gist:a79845e301de969017e714a96ffee6da
Multiple Loops for FacetWP
<?php
$args = array(
'post_type' => 'location',
'posts_per_page' => -1,
'order' => 'ASC',
'orderby' => 'title',
'facetwp' => true,
'tax_query' => array(
array(
'taxonomy' => 'advertiser-level',