Skip to content

Instantly share code, notes, and snippets.

@rossberenson
rossberenson / functions.php
Last active March 26, 2020 18:47 — forked from jo-flynn/functions.php
Get Template Part With Arguments ( Forked incase if author removes it )
<?php
/**
* Load a template part & pass in variables declared in caller scope. Optionally return as a string.
* @param string $path path to template file, minus .php (eg. `content-page`, `partial/folder/template-name`)
* @param array $args map of variables to load into scope
* @param bool $echo echo or return rendered template
* @return null or rendered template string
*/
function rb_get_template_part($path, $args = [], $echo = true) {
if (!empty($args)) {
@rossberenson
rossberenson / webpack.config.js
Created July 8, 2023 02:35 — forked from bahiirwa/webpack.config.js
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' );
@rossberenson
rossberenson / functions.php
Created March 26, 2024 21:30 — forked from simplistik/functions.php
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.
*