Skip to content

Instantly share code, notes, and snippets.

@jaybuys
jaybuys / searchwp-custom-weight.php
Last active Sep 22, 2017
Functions for custom weighting in Search WP
View searchwp-custom-weight.php
/*
* SearchWP Filter - Join the postmeta table so we can grab the resource publication date to add weight to it later.
*/
function hnn_searchwp_query_main_join( $sql, $engine ) {
global $wpdb;
if (isset($_GET['test']) && $_GET['test'] == 'true') {
$meta_key = 'publication_date'; // the meta_key you want to order by
$sql = $sql . " LEFT JOIN {$wpdb->postmeta} ON {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '{$meta_key}'";
}
echo $sql . '<br/><br/>';
@jaybuys
jaybuys / functions.php
Last active Dec 29, 2019
WordPress Visual Composer Mods
View functions.php
function vc_update_defaults() {
// Default single image to size "full"
$param = WPBMap::getParam( 'vc_single_image', 'img_size' );
$param['value'] = 'full';
vc_update_shortcode_param( 'vc_single_image', $param );
// Modify button 2 styles to use custom colors
$colors_arr = array(
__( 'Custom Color #1', 'js_composer' ) => 'custom_classname_1',
__( 'Custom Color #2', 'js_composer' ) => 'custom_classname_2'
@jaybuys
jaybuys / promo-rollover.js
Created Dec 10, 2013
Simple jQuery function to add rollover functionality to promo boxes. Adds/Removes an "over" class to the main container for CSS styling and has a click function so that the entire promo box will be clickable to the hyperlink housed inside.
View promo-rollover.js
$(function() {
// Promo rollovers
$('.promo').mouseover(function() {
$(this).addClass('over');
}).mouseout(function() {
$(this).removeClass('over');
}).click(function() {
location.href = $(this).find('a').attr('href');
});
});
@jaybuys
jaybuys / woo-slider-content-filter.php
Last active Aug 25, 2017
Make WooSlider plugin show full HTML content instead of excerpts in slide layout. Place this code in your WordPress theme functions.php file.
View woo-slider-content-filter.php
<?php
add_filter( 'wooslider_slides_layout_html', 'wooslider_custom_content', 10, 3);
function wooslider_custom_content ( $content, $args, $post ) {
global $post;
$image = get_the_post_thumbnail( get_the_ID() );
if ( 'true' == $args['link_slide'] || 1 == $args['link_slide'] ) {
$wooslider_url = get_post_meta( get_the_ID(), '_wooslider_url', true );