Skip to content

Instantly share code, notes, and snippets.

View braginteractive's full-sized avatar

Brad Williams braginteractive

View GitHub Profile
@braginteractive
braginteractive / _hero.scss
Created May 10, 2017 18:26
Sass styles for Homepage Hero
.sp-hero {
min-height: 500px;
background-position: center top;
background-size: cover;
width: 100%;
background-repeat: no-repeat;
position: relative;
h1 {
color: $white;
@braginteractive
braginteractive / hero-banner.php
Created May 10, 2017 18:29
Hero Banner Template Part
<?php
$hero_image = get_theme_mod( 'hero_image', '' );
$hero_text = get_theme_mod( 'hero_text', '' );
?>
<?php if ($hero_image != '') : ?>
<div class="sp-hero" style="background-image: url('<?php echo esc_url( $hero_image ); ?>')">
<h1><?php echo $hero_text; ?></h1>
</div>
<?php endif; ?>
@braginteractive
braginteractive / widgets.php
Created May 10, 2017 18:42
3 footer widget areas
<?php
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function strappress_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'strappress' ),
'id' => 'sidebar-1',
@braginteractive
braginteractive / footer.php
Created May 10, 2017 18:44
Footer with 3 widget areas
@braginteractive
braginteractive / echo-post-meta.php
Created June 1, 2017 19:24
Echo all Post Meta Data
<?php
$myvals = get_post_meta(get_the_ID());
foreach($myvals as $key=>$val)
{
echo $key . ' : ' . $val[0] . '<br/>';
}
?>
@braginteractive
braginteractive / bootstrap-walker-menu.php
Last active February 14, 2020 16:57
WordPress Walker Menu for Bootstrap
<?php
// Custom Walker Class for Bootstrap Menu
add_action( 'after_setup_theme', 'bootstrap_setup' );
if ( ! function_exists( 'bootstrap_setup' ) ):
function bootstrap_setup(){
class Bootstrap_Walker_Nav_Menu extends Walker_Nav_Menu {
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent<ul class=\"dropdown-menu\">\n";
}
@braginteractive
braginteractive / customizer.php
Created December 13, 2017 19:43
Add Bootswatch to StrapPress
if ( class_exists('Kirki') ) {
Kirki::add_config( 'strappress_theme', array(
'capability' => 'edit_theme_options',
'option_type' => 'theme_mod',
) );
/* Add Bootswatch to Colors Section */
Kirki::add_field( 'strappress_theme', array(
'type' => 'radio-image',
'settings' => 'bootswatch_css',
@braginteractive
braginteractive / wordpress-excerpt-function.php
Created December 22, 2017 18:56
Edit the WordPress excerpt to remove everything after the first sentence.
/**
* Find the first period in the excerpt and remove everything after it.
*
*
* @param string $excerpt The post excerpt.
*/
function end_with_sentence($excerpt) {
return substr($excerpt,0,strpos($excerpt,'.')+1);
}
add_filter( 'the_excerpt', 'end_with_sentence');
@braginteractive
braginteractive / posts-pagination.php
Created December 22, 2017 19:08
Font Awesome Posts Pagination for WordPress
the_posts_pagination (
array(
'prev_text' => '<i class="fa fa-arrow-left" aria-hidden="true"></i><span class="screen-reader-text">' . __( 'Previous Page', 'textdomain' ) . '</span>',
'next_text' => '<span class="screen-reader-text">' . __( 'Next Page', 'textdomain' ) . '</span><i class="fa fa-arrow-right" aria-hidden="true"></i>',
)
);
@braginteractive
braginteractive / logo-size.css
Created January 22, 2018 22:20
Additional CSS Logo Customization
.logo a img {
max-width: 250px;
}