Skip to content

Instantly share code, notes, and snippets.

@jaredatch
jaredatch / gist:1256954
Last active June 26, 2022 15:26
Using the template_include filter in WordPress
<?php
add_filter( 'template_include', 'ja_template_check' );
function ja_template_check( $template ) {
if ( is_category() ){
// Get category information
$cat = get_query_var( 'cat' );
$category_info = get_category( $cat );
// News sub-categories, where 7 is the ID for News
@jaredatch
jaredatch / functions.php
Created March 16, 2017 14:31
WPForms disable multipage scroll
<?php
/**
* Disable multipage scroll
*
*/
function wpf_disable_multipage_scroll() {
?>
<script type="text/javascript">window.wpforms_pageScroll = false;</script>
<?php
}
function user_function_restrict_content( $atts, $content = null ) {
if ( is_user_logged_in() && !is_null($content) && !is_feed() ) {
return do_shortcode( $content );
} else {
return 'Sorry, this content is only available for logged users.';
}
}
add_shortcode( 'member', 'user_function_restrict_content' );
@jaredatch
jaredatch / comments.php
Created November 4, 2016 13:29
WordPress Facebook Comments Lazy Load
<?php
/*
* If the current post is protected by a password and
* the visitor has not yet entered the password we will
* return early without loading the comments.
*/
if ( post_password_required() ) {
return;
}
?>
@jaredatch
jaredatch / functions.php
Last active February 28, 2022 22:04
WordPress Search Autocomplete using WP REST API v2
<?php
/**
* Enqueue scripts and styles.
*
* @since 1.0.0
*/
function ja_global_enqueues() {
wp_enqueue_style(
'jquery-auto-complete',
@jaredatch
jaredatch / functions.php
Created August 5, 2015 19:05
Remove rogue paragraph from the_content
<?php
/**
* Remove empty paragraph tags
*
* @since 1.0.0
* @param string $content
* @return string
*/
function ja_remove_empty_tags( $content ){
// clean up p tags around block elements
@jaredatch
jaredatch / functions.php
Last active February 28, 2022 22:04
Disable TinyMCE for specific page
<?php
/**
* Disable visual TinyMCE editor for specifc page/post
*
* @since 1.0.0
*/
function ja_disable_fancy_editor( $can ) {
global $post;
if ( 3441 == $post->ID ) {
@jaredatch
jaredatch / gist:1562aa6de1bc33db0bb3
Created February 13, 2015 17:20
Change author box title text in Genesis
<?php
/**
* Change "About" text in author box titles for single posts
*
* @since 1.0.0
* @param string $title
* @param string $context
* @return string
*/
function ja_author_box_title( $title, $context ) {
@jaredatch
jaredatch / wp-disable-feeds.php
Created November 15, 2012 17:28 — forked from ramseyp/wp-disable-feeds.php
Disable Feeds for WordPress site
<?php
/**
* Disable feeds
*
* @return string die
*/
function ja_disable_feed() {
wp_die( 'No feed available, please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!' );
}
@jaredatch
jaredatch / functions.php
Created September 21, 2012 05:52 — forked from billerickson/functions.php
Add Custom Image Sizes to Media Uploader
<?php
/**
* Add Custom Image Sizes to Media Uploader
* @author Pippin Williamson
* @link http://pippinsplugins.com/add-custom-image-sizes-to-media-uploader/
*
* @param array $sizes
* @return array
*/