Skip to content

Instantly share code, notes, and snippets.

View barbwiredmedia's full-sized avatar

Barbara Talbot barbwiredmedia

View GitHub Profile
@barbwiredmedia
barbwiredmedia / WP Templates: Video Loop in Modal
Last active December 23, 2015 08:59
Wordpress - Bootstrap Modal - Mediaelement.js - Advanced Custom Fields - The Loop - Video Popups - Custom Post Type - HTML5 : Loop through a CPT with ACF, with a video name variable hosted on a CDN. Show on click, hide on end, and restart from beginning of clip
<?php $loop = new WP_Query(array('post_type' => 'video-faq', 'posts_per_page' => 30, 'order' => 'ASC', 'orderby' => 'menu_order')); ?>
<?php $i = 1; //get the number count ?>
<?php while ($loop->have_posts()) : $loop->the_post(); ?>
<?php $videoName = get_field('video_file_name'); ?>
<!--Button to trigger popup-->
<p><?php echo $i;?>. <a href="#question<?php echo $i;?>" role="button" data-toggle="modal"><?php the_title(); ?></a></p>
<div id="question<?php echo $i;?>" class="modal hide fade video-pop" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-body">
<?php echo do_shortcode('[video mp4="http://bitcast-a.bitgravity.com/netcom/ingage/html5/' . $videoName . '.mp4" ogg="http://bitcast-a.bitgravity.com/netcom/ingage/html5/' . $videoName . '.ogv" webm="http://bitcast-a.bitgravity.com/netcom/ingage/html5/' . $videoName . '.webm" poster="/assets/img/poster-484x362.png" preload="true" fullscreen="false" volume="false" width="484" height="362" ]'); ?>
@barbwiredmedia
barbwiredmedia / Wordpress - CSS
Created September 23, 2013 20:36
Wordpress - CSS : Wordpress generated classes with styling
/* ==========================================================================
WordPress Generated Classes
See: http://codex.wordpress.org/CSS#WordPress_Generated_Classes
========================================================================== */
.aligncenter { display: block; margin: 0 auto; }
.alignleft { float: left; margin: 0px 20px 20px 0; }
.alignright { float: right; margin: 0px 0 20px 20px; }
figure.alignnone { margin-left: 0; margin-right: 0; }
@barbwiredmedia
barbwiredmedia / Wordpress - Functions
Last active December 23, 2015 18:39
Wordpress - Functions: Creates custom menus, register my menus, wp nav menu
// Creates custom menus
add_action( 'init', 'register_my_menus' );
function register_my_menus() {
register_nav_menus(
array(
'header-nav-1' => __( 'Top Nav' ),
'header-nav-2' => __( 'Header main' ),
'footer-nav' => __( 'Footer Nav' ),
'policy-nav'=> __('policy Nav')
)
@barbwiredmedia
barbwiredmedia / Wordpress - Templates:
Created September 24, 2013 21:48
Wordpress - Templates: wp_get_nav_menu_object , wp_nav_menu To create a navigation menu with a header right above it. Calls the menu from WP and uses the title founded under Appearance > Menus and puts it in a header tag
<?php
$menu_location = 'Footer-Nav-Column-1';
$menu_locations = get_nav_menu_locations();
$menu_object = (isset($menu_locations[$menu_location]) ? wp_get_nav_menu_object($menu_locations[$menu_location]) : null);
$menu_name = (isset($menu_object->name) ? $menu_object->name : '');
echo ('<h4>');
echo esc_html($menu_name);
echo ('</h4>');
wp_nav_menu(array('theme_location' => $menu_location, 'menu_class' => 'nav'));
?>
@barbwiredmedia
barbwiredmedia / Functions.php
Created October 18, 2013 22:29
Wordress - Functions :Creating breadcrumbs listing pages post parents and children
//Bread crumbs created
function wordpress_breadcrumbs() {
$delimiter = '|';
$currentBefore = '<span class="current">';
$currentAfter = '</span>';
if ( !is_home() && !is_front_page() || is_paged() ) {
echo '<div id="crumbs">';
global $post;
if ( is_page() && !$post->post_parent ) {
echo $currentBefore;
@barbwiredmedia
barbwiredmedia / Wordpress - Templates
Last active December 26, 2015 08:29
Wordpress Templates Query for Posts. Finds child posts/ ancestors. This will grab the currents page ID number and use it as the post parent and bring back all child posts of that ID. Can be used with static ID as well
<ul>
<?php
//Queryies for pages that are children of the current page
$this_page_id = $wp_query->post->ID; ?>
<?php query_posts(array('showposts' => 5, 'post_parent' => $this_page_id, 'post_type' => 'page'));
while (have_posts()) {
the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title() ?></a></li>
<?php } ?>
@barbwiredmedia
barbwiredmedia / Wordpress Templates
Created October 23, 2013 18:37
Wordpress Temples: This creates a conditional based on the parent page ID. If ( specific page || checks for existence of having our parent page || looks for all ancestors of our parent and limits it to those children only ) The query brings back posts that are children of our parent.
<?php
//Set up the variables of the parent page ID's
$parentPageID = '509';
?>
<?php if (is_page($parentPageID) || $post->post_parent == $parentPageID || ($post->ancestors && in_array($parentPageID, $post->ancestors) )) { ?>
<h3>Child Pages</h3>
<ul>
<?php
//Queries for all pages that are children of our parent ID
?>
@barbwiredmedia
barbwiredmedia / Wordpress Templates
Created October 24, 2013 16:54
WordPress Templates - Multidimensional Array , while loop , loopcount. Creates an array of multiple variables to loop through until finished. PageID is parent and is used to find children / ancestors
<?php
$argsArray = array(
array("pageID" => '496', "catID" => '41'),
array("pageID" => '519', "catID" => '35'),
array("pageID" => '522', "catID" => '40'),
array("pageID" => '1687', "catID" => '38'),
array("pageID" => '524', "catID" => '36'),
);
@barbwiredmedia
barbwiredmedia / Roots Theme config.php
Created October 29, 2013 16:56
Wordpress Roots Theme config.php Conditional tag checks to keep template/ page from displaying sidebar. This is that array example http://roots.io/
array(
'is_404',
'is_front_page',
array('is_page', array('instructors', '',)), //page-instructors.php
array('is_page', array('contact', '',)),
array('is_singular', array('instructor', '',)), // single-instructor.php
array('is_singular', array('class', '',))
),
@barbwiredmedia
barbwiredmedia / Template.php
Created November 4, 2013 21:25
Wordpress Plugins - Templates ACF advanced custom fields repeater field with sub fields
<?php while (the_repeater_field('repeater_name_here')): ?>
<?php the_sub_field('repeater_sub_here'); ?>
<?php endwhile; ?>