Skip to content

Instantly share code, notes, and snippets.

Avatar

Brad Williams braginteractive

View GitHub Profile
View echo-post-meta.php
<?php
$myvals = get_post_meta(get_the_ID());
foreach($myvals as $key=>$val)
{
echo $key . ' : ' . $val[0] . '<br/>';
}
?>
@braginteractive
braginteractive / footer.php
Created May 10, 2017
Footer with 3 widget areas
View footer.php
@braginteractive
braginteractive / widgets.php
Created May 10, 2017
3 footer widget areas
View widgets.php
<?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 / hero-banner.php
Created May 10, 2017
Hero Banner Template Part
View hero-banner.php
<?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 / _hero.scss
Created May 10, 2017
Sass styles for Homepage Hero
View _hero.scss
.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 / template-home.php
Created May 10, 2017
Get Template Part for Homepage banner
View template-home.php
<?php get_template_part( 'template-parts/home/hero', 'banner' ); ?>
@braginteractive
braginteractive / template-home.php
Created May 10, 2017
Code to display Hero Banner and Text
View template-home.php
<?php
$hero_image = get_theme_mod( 'hero_image', '' );
$hero_text = get_theme_mod( 'hero_text', '' );
?>
<div class="sp-hero" style="background-image: url('<?php echo esc_url( $hero_image ); ?>')">
<h1><?php echo $hero_text; ?></h1>
</div>
@braginteractive
braginteractive / customizer.php
Last active May 12, 2017
Hero Banner settings for WordPress Customizer
View customizer.php
<?php
if ( class_exists( 'Kirki' ) ) {
/**
* Add the theme configuration
*/
Kirki::add_config( 'strappress_theme', array(
'option_type' => 'theme_mod',
'capability' => 'edit_theme_options',
) );
@braginteractive
braginteractive / customizer.php
Last active May 12, 2017
Kirki code to add Typography to WordPress theme
View customizer.php
<?php
/**
* StrapPress Theme Customizer
*
* @package StrapPress
*/
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
@braginteractive
braginteractive / tgm-plugin-activation.php
Created May 1, 2017
TGM Plugin Activation file for Kirki
View tgm-plugin-activation.php
<?php
/**
* This file represents an example of the code that themes would use to register
* the required plugins.
*
* It is expected that theme authors would copy and paste this code into their
* functions.php file, and amend to suit.
*
* @see http://tgmpluginactivation.com/configuration/ for detailed documentation.
*