Skip to content

Instantly share code, notes, and snippets.

them-es

Block or report user

Report or block them-es

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@them-es
them-es / functions.php
Last active Nov 21, 2019
Multisite: Duplicate Theme Customizer values across network
View functions.php
<?php
/**
* Duplicate specific Theme Customizer values across Multisite network
*
*/
function my_theme_customize_multisite_duplicate() {
if ( is_multisite() ) {
// Get existing values from current blog as array
@them-es
them-es / functions.php
Last active Nov 30, 2019
WordPress Multiblog: Combine WP-API feeds from different websites and cache the output
View functions.php
<?php
/**
* WordPress "Multiblog"
*
* Combine multiple WP-API feeds sorted by date and cache the output via Transients API
*/
// Cache transients in database: https://codex.wordpress.org/Transients_API
$transient = 'wp_api_remote_posts_cache;
$content = get_transient( $transient ); // Try to get cached data
@them-es
them-es / functions.php
Last active Dec 9, 2019
Include ACF fields in WP-API response
View functions.php
<?php
/**
* Include ACF fields in REST API response
*
*
*/
function my_theme_acf_to_rest_api( $response, $post, $request ) {
if ( ! function_exists( 'get_fields' ) ) {
return $response;
}
@them-es
them-es / functions.php
Created Dec 9, 2019
Include Gutenberg blocks in WP-API response
View functions.php
<?php
/**
* Include all Gutenberg blocks from content in REST API response
*
*
*/
function my_theme_blocks_to_rest_api( $response, $post, $request ) {
if ( ! function_exists( 'parse_blocks' ) ) {
return $response;
}
@them-es
them-es / functions.php
Last active Mar 10, 2020
Make Polylang compatible with the WP-API. Query language specific WP-API posts via a parameter and add the post language as a new REST field.
View functions.php
<?php
/**
* https://developer.wordpress.org/reference/hooks/rest_this-post_type_query
*
* Query language specific posts via "lang" parameter: /wp-json/wp/v2/posts?lang=en
*/
function my_theme_filter_rest_post_query( $args, $request ) {
$lang_parameter = $request->get_param('lang');
You can’t perform that action at this time.