Skip to content

Instantly share code, notes, and snippets.

View addisonhall's full-sized avatar

Addison Hall addisonhall

View GitHub Profile
@addisonhall
addisonhall / Page-before-body-closing.html
Last active October 10, 2023 22:07
Webflow Hero Slider using Swiper JS
<script>
/**
* Activate swiper.js for testimonials
*/
doHeroSlider();
function doHeroSlider() {
// get hero slider element
const heroSlider = document.getElementById('heroSlider');
// shut it down if slider isn't present
@addisonhall
addisonhall / ACF_random_image.php
Last active November 22, 2021 21:22
ACF random image for GeneratePress background image URL
<?php
add_filter( 'generate_page_hero_background_image_url', function( $url ) {
$headers = array(
esc_url(get_field('radnomizer_image_one')),
esc_url(get_field('radnomizer_image_two')),
esc_url(get_field('radnomizer_image_three')),
esc_url(get_field('radnomizer_image_four')),
esc_url(get_field('radnomizer_image_five'))
);
@addisonhall
addisonhall / get_post_title_shortcode.php
Created September 6, 2021 18:05
Simple Wordpress shortcode to output current post title
/**
* Output the post title.
* [gpc_post_title]
*/
add_shortcode( 'gpc_post_title', 'gpc_post_title_func' );
function gpc_post_title_func() {
return get_the_title();
}
@addisonhall
addisonhall / gp-hide-paging-navigation.css
Last active November 12, 2020 19:23
Hide GeneratePress post navigation via CSS
.paging-navigation {
display: none;
}
@addisonhall
addisonhall / wp-site-tagline-shortcode.php
Last active November 10, 2020 14:42
Shortcode to output site tagline
/**
* Output site tagline.
* [gp_site_tagline]
*/
function gp_output_site_tagline_func() {
return get_bloginfo( 'description' );
}
add_shortcode( 'gp_site_tagline', 'gp_output_site_tagline_func' );
@addisonhall
addisonhall / function-enqueue-cpt-css.php
Last active April 23, 2020 16:06
Wordpress: Enqueue CSS for custom post type only
<?php
/**
* Enqueue specific CSS styles or javascript for a custom post type (cpt).
*/
add_action( 'wp_enqueue_scripts', 'my_cpt_scripts' );
function my_cpt_scripts() {
if ( is_singular( 'custom_post_type_name' ) || is_post_type_archive( 'custom_post_type_name' ) ) {
wp_enqueue_style( 'cpt-style', get_stylesheet_directory_uri() . '/css/your-cpt-style.css', false, '', 'all');
}
@addisonhall
addisonhall / wp_user_shortcodes.php
Created October 12, 2018 19:21
Handy user shortcodes for WordPress
/**
* Add current user shortcode
*/
add_shortcode( 'current-user' , 'gpc_get_current_user' );
function gpc_get_current_user() {
$user = wp_get_current_user();
return $user->display_name;
}
/**
@addisonhall
addisonhall / wpsp_remove_permalinks.php
Last active December 2, 2017 16:18
Add this to WordPress functions.php to selectively disable permalinks on the WP Show Posts plugin. (https://wpshowposts.com/)
@addisonhall
addisonhall / content-cpt-output-list.php
Last active November 4, 2017 20:21
WordPress shortcode example: output custom post type list by custom taxonomy
<?php
/**
* Partial for custom_post_type_list shortcode output.
*
* @package ChildTheme
*/
if ( ! defined( 'ABSPATH' ) ) exit; ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
@addisonhall
addisonhall / shortcodes-ultimate-columns-override.css
Created September 22, 2017 18:54
Mo' better responsive row and column styling for WP Shortcodes Ultimate
/* Shortcodes Utlimate Rows and Columns */
.gpc .su-row {
margin: 0 -2% 1.5em -2%;
}
.gpc .su-row .su-column {
margin-left: 0;
margin-right: 0;
padding: 0 2% 0;
}
.gpc .su-column-size-1-1 { width: 100%; }