Skip to content

Instantly share code, notes, and snippets.

@FriendlyWP
FriendlyWP / page-alt-header.php
Created March 30, 2022 16:49
WordPress page template for GeneratePress
<?php
/**
* Template Name: No-Image Header
* Template Post Type: post, page
*
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
@FriendlyWP
FriendlyWP / functions.php
Last active February 10, 2021 21:26
Accessible pager facet for FacetWP
add_filter( 'facetwp_facet_html', 'local_per_page', 10, 2);
function local_per_page ( $output, $params ) {
if ( 'pager' == $params['facet']['type'] ) {
$output = str_replace( 'class="facetwp-per-page-select"', 'class="facetwp-per-page-select" aria-label="Per Page Options"', $output );
}
return $output;
}
/*********************
Breakpoints
*********************/
/* usage: @include bp(tablet) { // your styles here } */
@mixin bp($point) {
@if $point == widescreen { // 1440px
@media (min-width: 90em) { @content ; }
}
@elseif $point == tv { // 1300px
@media (min-width: 81.25em) { @content ; }
@FriendlyWP
FriendlyWP / _gutenberg-columns.scss
Last active December 13, 2018 17:53
Responsive SCSS styles for .wp-block-columns with nice spacing. Columns are full-width to the container.
@import "breakpoints"; // for bp mixin see https://snippets.cacher.io/snippet/fc10ef4581746c8e4b96
$margin-right: 4.7619%; /* this is % equiv of 40px/2.5rem, but it could be anything. */
.wp-block-columns {
$wrap: &;
display:flex;
flex-direction: row;
flex-wrap:wrap;
margin:0 -#{$margin-right} 0 0;
@FriendlyWP
FriendlyWP / _sidebar.scss
Created June 2, 2018 16:18
Automatically resize footer widgets based on number of widgets present. Uses css flexbox.
.footer-widgets {
@include breakpoint(tablet) {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
margin-right: -3rem;
}
@FriendlyWP
FriendlyWP / group_5a0cb501d0249.json
Created November 16, 2017 18:26
get_all_custom_field_meta issue
{
"key": "group_5a0cb501d0249",
"title": "Location & Hours",
"fields": [
{
"key": "field_5a0cb50f1fae4",
"label": "Header Hours & Location info",
"name": "header_hours",
"type": "wysiwyg",
"instructions": "",
@FriendlyWP
FriendlyWP / index.php
Last active October 15, 2016 17:41
See if "posts page" is set in Settings > Reading; If it is, display that page's title before the posts.
<?php
// See if "posts page" is set in Settings > Reading, aka is_home()
// If it is, display this page's title before the posts
$page_for_posts = get_option( 'page_for_posts' );
if ($page_for_posts) { ?>
<header class="page-header">
<h1 class="page-title" itemprop="headline">
<?php echo get_queried_object()->post_title; ?>
</h1>
</header> <?php // end article header ?>
@FriendlyWP
FriendlyWP / functions.php
Created October 12, 2016 19:26
Sidebar menu shortcode
add_shortcode('sidebar-menu','fwp_simplesidenav');
function fwp_simplesidenav( $atts, $content = null) {
global $post;
$current_page = $post->ID;
extract( shortcode_atts( array(
'exclude' => '',
'exclude_children_of' => '',
'exclude_tree' => '',
'children_of' => $current_page,
@FriendlyWP
FriendlyWP / functions.php
Created July 5, 2016 20:26
Shortcode to insert non-breaking spaces in WordPress content
//[nbsp] shortcode
add_shortcode( 'nbsp', 'nbsp_shortcode' );
function nbsp_shortcode( $atts, $content = null ) {
$a = shortcode_atts( array(
'num' => 1,
), $atts );
$content = str_repeat('&nbsp', $a['num']);
return $content;
}
@FriendlyWP
FriendlyWP / functions.php
Last active July 6, 2016 14:35
Run Jetpack in development mode on localhost only
/****
USE JETPACK IN DEVELOPMENT MODE ON LOCALHOST
*****/
if ( $_SERVER['SERVER_NAME'] == 'gladdestthing.dev' ) { // replace gladdestthing.dev with local url
add_filter( 'jetpack_development_mode', '__return_true' );
}