Skip to content

Instantly share code, notes, and snippets.

@teledirigido
teledirigido / import_files.php
Created July 6, 2015 01:44
Create post, add attachment and update field via ACF
<?php
/*
*
* This small scripts creates a post and attaches a file using Advanced custom field.
*
* Created by Miguel Garrido
* miguel.co.nz | [email protected]
*
* Notes:
@senlin
senlin / language-independent-acf-theme-options-output.php
Last active June 26, 2024 08:58
How to get language independent ACF theme options on a WPML site
<?php
/**
* To get this to work, you need to tinker with the acf/settings/ filter and reset the default language
* so that the get_field() function returns the correct results even when not on the default language.
*
* You can add the filter before you call the get_field() function and then call it again with the current
* language to reset it again, so it will affect other pages.
*
* answer courtesy of James of ACF Support
*/
@MikeNGarrett
MikeNGarrett / wp-config.php
Last active May 12, 2025 16:13
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@wpmark
wpmark / wp-query-orderby-muliple-meta-keys.php
Created November 18, 2015 12:48
WP_Query Ordered By Multiple Meta Keys
<?php
/* build a new wp_query */
$classes = new WP_Query(
array(
'post_type' => 'wpmark_class_time', // post type to query
'posts_per_page' => -1, // get all the posts not limited
'meta_query' => array(
'relation' => 'AND',
'day' => array( // give the first meta key array an array key
'key' => '_wpmark_day',
@n7studios
n7studios / gravity-forms-move-progress-bar-bottom.php
Created November 19, 2015 16:14
Gravity Forms - Move Progress Bar to Bottom of Form
<?php
/**
* Plugin Name: Gravity Forms: Move Progress Bar to Bottom of Form
* Plugin URI: http://www.n7studios.co.uk
* Version: 1.0.0
* Author: n7 Studios
* Author URI: http://www.n7studios.co.uk
* Description: Moves the progress bar from the top to the bottom of the Gravity Form. The Start Paging section of the form MUST have a CSS class = progress-bar-bottom
*/
@mgibbs189
mgibbs189 / 01_Query_Arguments.php
Last active August 27, 2023 10:11
FacetWP - show both a Google Map and a result listings
<?php
return array(
"post_type" => "park",
"post_status" => "publish",
"posts_per_page" => 100
);
@richaber
richaber / filter_oembed.php
Created January 11, 2016 05:08
Filter the WordPress oembed_fetch_url and oembed_result to maintain URL query args
<?php
/**
* Add params back to oEmbed provider request URL.
*
* WordPress runs the embed URL through urlencode prior to constructing it's oEmbed provider endpoint call.
* This renders any passed in URL query params useless for Vimeo embeds (and probably others).
* This filter function will decode those URL query param, and add them as proper query args to the provider URL.
*
* The first function param, $provider, is the oEmbed provider endpoint.
@robwent
robwent / clean_wordpress_head.php
Last active October 21, 2022 02:38
A collection of snippets for a Wordpress theme's function.php file to clean up the output
<?php
/**
* Core output
**/
//Remove the generator tag
remove_action('wp_head', 'wp_generator');
//Remove the frontend admin bar while in development
#!/bin/bash
cat posts.json | jq -c -M '.[]' | sed 's/\\"/\\\\"/g' | \
while read single_post;
do
post_id=$(echo $single_post | jq '.ID');
echo $single_post > post/$post_id.json;
done
echo "done"
@Jany-M
Jany-M / WP_flush_cache_and_transients.php
Last active January 20, 2025 12:13
[WordPress] Flush Object Cache (Memcached) & Transients - Admin buttons
<?php
// Flush Cache from Admin bar
function flush_memcache_button() {
global $wp_admin_bar;
// If User isnt even logged in or if admin bar is disabled
if ( !is_user_logged_in() || !is_admin_bar_showing() )
return false;