Skip to content

Instantly share code, notes, and snippets.

Avatar

Brad Dalton braddalton

View GitHub Profile
@braddalton
braddalton / hero_text.html
Created Aug 14, 2021
Unique Hero HTML Overlaying Hero Image In Parallax Pro https://wpsites.net/?p=105145
View hero_text.html
<h3 class="widgettitle widget-title">Unique Title.</h3><div class="textwidget"><p>Unique hero overlay content for each page template.<br>Mobile responsive in design and boasts HTML5 markup.<br><a class="button" href="#">Call to Action</a></p></div>
View functions.php
add_filter('the_category_list', 'only_show_first_category');
function only_show_first_category( $cats ) {
return [$cats[0]];
}
View functions.php
add_action( 'wp_enqueue_scripts', 'genesis_enqueue_lightbox_script_styles' );
function genesis_enqueue_lightbox_script_styles() {
wp_enqueue_script( 'lightbox-js', get_stylesheet_directory_uri() . '/lightbox.js', [ 'jquery' ], genesis_get_theme_version(), true );
wp_enqueue_style( 'lightbox-styles', get_stylesheet_directory_uri() . '/lightbox.css', [], genesis_get_theme_version() );
}
@braddalton
braddalton / functions.php
Created Nov 18, 2020
1st Paginated Archive Page 1 post
View functions.php
add_action( 'pre_get_posts', 'posts_per_page_home' );
function posts_per_page_home($query) {
if ( $query->is_home() && $query->is_main_query() && get_query_var( 'paged' ) < 2 ) {
$query->set( 'posts_per_page', '1' );
}
}
@braddalton
braddalton / functions.php
Created Nov 18, 2020
Set Posts Per Page On Home Page
View functions.php
add_action( 'pre_get_posts', 'posts_per_page_home' );
function posts_per_page_home($query) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'posts_per_page', '1' );
}
}
@braddalton
braddalton / functions.php
Last active Oct 10, 2020
Using get_post_meta In Replace of ACF the_sub_field https://wpsites.net/?p=96847
View functions.php
$repeater_value = get_post_meta( get_the_ID(), 'content_area_light_background', true);
if ( $repeater_value ) :
for ( $i = 0; $i < $repeater_value; $i++ ) {
$meta_key = 'content_area_light_background_' . $i . '_light_background_sub_field';
$sub_field_value = get_post_meta( get_the_ID(), $meta_key, true );
echo $sub_field_value;
}
endif;
@braddalton
braddalton / functions.php
Last active Oct 10, 2020
ACF Repeater Sub Field Using get_sub_field https://wpsites.net/?p=96847
View functions.php
if ( have_rows( 'content_area_light_background' ) ) :
while ( have_rows( 'content_area_light_background' ) ) : the_row();
the_sub_field( 'light_background_sub_field' )
endwhile;
endif;
View breadcrumbs.php
$this->args = array(
'home' => __( 'Home', 'genesis' ),
'sep' =>
'list_sep' => ', ',
'prefix' => '<div class="breadcrumb">',
'suffix' => '</div>',
'heirarchial_attachments' => true,
'heirarchial_categories' => true,
'labels' => array(
'prefix' => __( 'You are here: ', 'genesis' ),
View archive.php
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
add_action( 'genesis_before_loop', 'wordpress_seo_plugins_breadcrumbs' );
function wordpress_seo_plugins_breadcrumbs() {
if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb('<div class="breadcrumb">','</div>');
}
}
@braddalton
braddalton / custom-html-widget.html
Created Jun 19, 2020
Before Header Utility Bar In Monochrome Pro https://wp.me/p1lTu0-j0n
View custom-html-widget.html
<div class="text">Call us today for help!<a class="" href="tel://1-800-555-2840">(800) 555-2840</a></div>