Add to functions.php function change_graphic_lib($array) { return array( ‘WP_Image_Editor_GD’, ‘WP_Image_Editor_Imagick’ ); } add_filter( ‘wp_image_editors’, ‘change_graphic_lib’ );
For more code ideas go to my GitHub gists:
https://gist.github.com/johnnya23
Order by Expiration
Using the post expirator plugin see useful plugins function my_custom_posts_query( $query, $args ){ if( $args[‘query’] == ‘expires_first’ ){ $query = array( ‘cat’ => 1, ‘order’ => ‘ASC’, ‘meta_key’ => ‘_expiration-date’, ‘orderby’ => ‘meta_value’ ); if(is_front_page())//optional $query[‘posts_per_page’] = 5; } return $query; } add_filter( ‘themeblvd_posts_args’, ‘my_custom_posts_query’, 10, 2 ); For woo products with variable category query […]
MySql Move Post Tags
When using Post Type Switcher the tags get left behind (this will move them ALL which isn’t always what you want). UPDATE wp_term_taxonomy SET taxonomy=’portfolio_tag’ WHERE taxonomy=’post_tag’ UPDATE wp_term_taxonomy SET taxonomy=’portfolio’ WHERE taxonomy=’category’
Left Tabs with Flyouts
Set shortcode (bootstrap) to pills: .tabs-left .tb-tabs-framed .tab-content { border-top-width: 1px; margin-left: 149px; } .tabs-left .nav-tabs, .tabs-left .nav-pills { width: 150px; float: left; } .tabs-left .nav-tabs>li, .tabs-left .nav-pills>li { border-left-width: 1px; float: none; border-top: solid 1px #ffffff; } .tabs-left .nav-pills>li { width: 110px; margin-left: 0; position: relative; -webkit-transition: width 0.3s; /* Safari */ transition: width […]
Pinwheel Image
The markup (using Jumpstart shortcode for bootstrap elements and putting over bg image in the builder) substitute <div class=”whatever”> for [html class=”whatever”] and </div> for [/html] . the html: [raw] [column size=”5/12″ wpautop=”false”] [html class=”inner left”]This is an example page. It’s different from a blog post because it wil[/html] [/column] [column size=”1/6″ wpautop=”true”] <!–Column 2…–> […]
Nivo Slider From ACF Gallery
Use this to create the html for the slider: function jma_nivo($input = array() ){ $defaults = array( ‘class’ => ”, ‘acf_field’ => ‘gallery’, ‘image_size’ => ‘tb_grid’, ‘thumb_size’ => ‘tb_thumb’, ‘post_id’ => ”, ‘image_ids’ => ”, ); foreach($defaults as $var => $default){ $args[$var] = isset($input[$var]) && $input[$var]? $input[$var]: $default; } extract($args); if(!$post_id){ global $post; $post_id = […]
Nivo Slider Nav Styling
/* slider nav and caption */ .tb-nivo-slider-wrapper .nivo-directionNav { height: 0; position:static; } .tb-nivo-slider-wrapper .nivo-directionNav a { top: 50%; transform: translate(0, -50%); position: absolute; background-image: none; width: 30px; height: 30px; opacity: 0; -webkit-transition: opacity 0.6s; /* Safari */ transition: opacity 0.6s; z-index: 100; } .tb-nivo-slider-wrapper:hover .nivo-directionNav a { opacity: 1; } .tb-nivo-slider-wrapper .nivo-directionNav a.nivo-prevNav { […]
Suppress Related Videos on Popups
For lightbox videos: function change_magnific_popup_iframe_setting(){ ?> <script> jQuery(window).load(function(){ jQuery(‘a[href*=”youtube.com/watch”]’).magnificPopup({ type: ‘iframe’, iframe: { patterns: { youtube: { index: ‘youtube.com’, id: ‘v=’, src: ‘//www.youtube.com/embed/%id%?rel=0&autoplay=1’ } } } }); }); </script> <?php } add_action(“wp_footer”, “change_magnific_popup_iframe_setting”);
PHP Caching
<?php //settings $cache_ext = ‘.html’; //file extension $cache_time = 3600; //Cache file expires afere these seconds (1 hour = 3600 sec) $cache_folder = ‘cache/’; //folder to store Cache files $ignore_pages = array(”, ”); $dynamic_url = ‘http://’.$_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’] . $_SERVER[‘QUERY_STRING’]; // requested dynamic page (full url) $cache_file = $cache_folder.md5($dynamic_url).$cache_ext; // construct a cache file $ignore […]