Skip to content

Instantly share code, notes, and snippets.

View danielhomer's full-sized avatar

Daniel Homer danielhomer

View GitHub Profile

Keybase proof

I hereby claim:

  • I am danielhomer on github.
  • I am danielhomer (https://keybase.io/danielhomer) on keybase.
  • I have a public key ASBnJ0x1yTYyLlmfFW6EbSrnV4BvsjO97NsdEs8oMTOMMgo

To claim this, I am signing this object:

@danielhomer
danielhomer / functions.php
Last active May 23, 2019 10:42
WordPress - Check network site for post before 404'ing
<?php
/**
* This filter will attempt to fetch a post from the main site if a post cannot be found
* on a child site.
**/
add_filter( 'the_posts', function( $posts, $wp_query ) {
$network_id = get_network()->site_id;
if ( ( ( count( $posts ) === 0 && is_single() ) || is_archive() || is_home() ) && get_current_blog_id() !== $network_id ) {