Skip to content

Instantly share code, notes, and snippets.

View jnarciso's full-sized avatar

Jason Narciso jnarciso

  • Teal Media
  • Wilmington, North Carolina
View GitHub Profile
@ControlledChaos
ControlledChaos / README.md
Last active September 14, 2024 00:13
Add srcset and sizes attributes to Advanced Custom Fields image uploads.

ACF Responsive Images

WordPress Snippet

Adds the srcset and sizes attributes to ACF image uploads. Requires installation of the Advanced Custom Fields plugin.

NOTE: ACF image field must be set to return the ID.

NOTE: WordPress needs image sizes with equal aspect ratios in order to generate the srcset, and does not use srcset when images are added as "Full Size".

@steveosoule
steveosoule / README.md
Last active June 22, 2022 14:55
Miva WordPress Hybrid Sample

WP-HEADER

Template

<mvt:do file="g.Module_Library_Utilities" name="g.datetime" value="Format_SOAP_DateTime( s.dyn_time_t )" />
<!-- !@! datetime: &mvt:global:datetime; -->

<div id="site-container">
	<div id="global-header"><mvt:item name="hdft" param="global_header" /></div>
@bjorn2404
bjorn2404 / wp_kses_post_tags.php
Last active July 9, 2024 18:13
WordPress allow iFrames with wp_kses_post filter
<?php
/**
* Add iFrame to allowed wp_kses_post tags
*
* @param array $tags Allowed tags, attributes, and/or entities.
* @param string $context Context to judge allowed tags by. Allowed values are 'post'.
*
* @return array
*/
@mattclements
mattclements / function.php
Last active September 30, 2025 07:50
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@EvanHerman
EvanHerman / check-if-element-in-viewport-on-scroll.js
Last active December 20, 2024 14:34
Check when an element comes into view (jQuery)
function isOnScreen(elem) {
// if the element doesn't exist, abort
if( elem.length == 0 ) {
return;
}
var $window = jQuery(window)
var viewport_top = $window.scrollTop()
var viewport_height = $window.height()
var viewport_bottom = viewport_top + viewport_height
var $elem = jQuery(elem)
@kjbrum
kjbrum / wp_gravity_forms_submit_button.php
Last active August 27, 2021 12:55
Change a Gravity Forms submit input to a button.
<?php
/**
* Change a Gravity Forms submit input to a button.
*
* @param string $button The string of the submit input html
* @param object $form A Gravity Form form object
* @return string Our modified submit button string
*/
function wp_gravity_forms_submit_button( $button, $form ) {
return "<button class='btn' id='gform_submit_button_{$form["id"]}'>{$form['button']['text']}</button>";
@brycejacobson
brycejacobson / page.php
Created March 4, 2015 17:48
WordPress Loop inside foreach to get posts under custom taxonomy.
<!-- Begin custom tax loop -->
<ul class="accordion" data-accordion>
<?php
//Retrieve custom taxonomy terms using get_terms and the custom post type.
$categories = get_terms('state');
//Iterate through each term
foreach ( $categories as $category ) :
?>
@pburtchaell
pburtchaell / styles.css
Last active February 12, 2025 08:45
VH and VW units can cause issues on iOS devices. To overcome this, create media queries that target the width, height, and orientation of iOS devices.
/**
* VH and VW units can cause issues on iOS devices: http://caniuse.com/#feat=viewport-units
*
* To overcome this, create media queries that target the width, height, and orientation of iOS devices.
* It isn't optimal, but there is really no other way to solve the problem. In this example, I am fixing
* the height of element `.foo` —which is a full width and height cover image.
*
* iOS Resolution Quick Reference: http://www.iosres.com/
*/
@mattbanks
mattbanks / taxonomy-query-loop.php
Created April 2, 2014 16:51
Loop through each taxonomy term, run a new WP_Query in each term
<?php
// Get terms
// http://codex.wordpress.org/Function_Reference/get_terms
// use $args array in second parameter if needed
$my_categories = get_terms( 'TERM_NAME_HERE' );
$my_categories_count = count( $my_categories );
if ( $my_categories_count > 0 && is_array( $my_categories ) ) {
echo '<div class="wrap">';
@davidpaulsson
davidpaulsson / wp-get_id_by_slug
Created February 26, 2014 06:20
WordPress: Get page ID from slug
// Usage:
// get_id_by_slug('any-page-slug');
function get_id_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
} else {
return null;
}