Skip to content

Instantly share code, notes, and snippets.

View braginteractive's full-sized avatar

Brad Williams braginteractive

View GitHub Profile
@braginteractive
braginteractive / extras.php
Created April 11, 2017 21:45
Add class to Read More link in WordPress
<?php
/**
* Customize the Read More Button
**/
function helpwp_modify_read_more_link() {
return '<a class="more-link btn btn-sm btn-primary" href="' . get_permalink() . '">View Tutorial</a>';
}
add_filter( 'the_content_more_link', 'helpwp_modify_read_more_link' );
@braginteractive
braginteractive / extras.php
Created April 11, 2017 21:58
Filter to add class to WordPress tags
<?php
/**
* Add Class to Tags
*/
function helpwp_add_tag_class($links) {
return str_replace('<a href="', '<a class="tag btn btn-sm btn-primary" href="', $links);
}
add_filter( "term_links-post_tag", 'helpwp_add_tag_class');
@braginteractive
braginteractive / header.php
Created April 11, 2017 22:10
Search icon from Navigation
<span class="navbar-text">
<i class="fa fa-search" aria-hidden="true"></i>
</span>
@braginteractive
braginteractive / header.php
Created April 11, 2017 22:11
Search form for jQuery toggle in WordPress
<div class="search-bar">
<div class="container">
<div class="row">
<div class="col-md-8 offset-md-2">
<?php get_search_form(); ?>
</div><!-- .col-md-8 -->
</div><!-- .row -->
</div><!-- .container -->
</div><!-- .search-bar -->
@braginteractive
braginteractive / _header.scss
Created April 11, 2017 22:15
Styles used for the Search Bar
.search-bar {
display: none;
padding: 2rem 0;
background-color: $brand-success;
box-shadow: inset 0px 1px 30px -2px rgba(0,0,0,0.75);
}
.fa-search {
&:hover {
color: rgba(255, 255, 255, 0.75);
@braginteractive
braginteractive / site.js
Created April 11, 2017 22:20
Toggle the search bar in WordPress
jQuery(document).ready(function($){
$('.fa-search').on('click', function() {
$('.search-bar').slideToggle();
});
});
@braginteractive
braginteractive / tracking.php
Last active April 11, 2017 22:41
Add Google Analytics to WordPress
<?php
/**
* Add Tracking Scripts
*/
function helpwp_google_analytics() { ?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
@braginteractive
braginteractive / functions.php
Created April 11, 2017 22:44
Add tracking to functions.php
<?php
/**
* Tracking Codes
*/
require get_template_directory() . '/inc/tracking.php';
@braginteractive
braginteractive / widgets.php
Created April 18, 2017 21:20
Resister the Contact widget area in WordPress theme
<?php
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function helpwp_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'helpwp' ),
'id' => 'sidebar-1',
@braginteractive
braginteractive / parent-categories.php
Created July 30, 2016 02:32
Just display the parent categories of a CPT taxonomy
$taxonomy = 'inventory_category';
$cat_args = array(
'taxonomy' => 'inventory_category',
'parent' => 0,
'number' => 10,
'hide_empty' => true
);
$terms = get_terms($cat_args);