Skip to content

Instantly share code, notes, and snippets.

Avatar

Brett Widmann goatboy91587

View GitHub Profile
@BurlesonBrad
BurlesonBrad / header-tracking-snippet.php
Created Jan 27, 2020
🚫No WordPress plugin needed to add tracking code to the header 👍
View header-tracking-snippet.php
function header_tag_analytics() { ?>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-XX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXX-XX');
</script>
// Add your Tweeder scripts Adroll scripts Facebook scripts BounceX scripts Optimizely scripts or whatever needs to be in the head
@mattradford
mattradford / acf_body_class.php
Last active Sep 18, 2020
Echo ACF custom field in body class
View acf_body_class.php
// ACF field added to body class
// Adapted from http://krogsgard.com/2012/wordpress-body-class-post-meta/
add_filter('body_class','tend_custom_field_body_class');
function tend_custom_field_body_class( $classes ) {
global $wp_query;
$postid = $wp_query->post->ID;
if ( is_page_template('template-service-index.php') ) {
@danielbachhuber
danielbachhuber / gist:7126249
Last active Jun 1, 2020
Include posts from authors in the search results where either their display name or user login matches the query string
View gist:7126249
<?php
/**
* Include posts from authors in the search results where
* either their display name or user login matches the query string
*
* @author danielbachhuber
*/
add_filter( 'posts_search', 'db_filter_authors_search' );
function db_filter_authors_search( $posts_search ) {
You can’t perform that action at this time.