Category: Code Snippets
-

Fix WordPress Navigation -Same Posts On All Pages Problem
[ad_1] Divi is a WordPress theme that web designers do not want you to know. It comes with a drag-and-drop theme builder. You can build beautiful looking unique websites without touching a line of code. Just choose from one of the many pre-made layouts, or pick elements and arrange them any way you like. Divi…
-

Archive Page For Custom Taxonomy
[ad_1] By OutsourcedContent — on December 9, 2017 Here is the Query. Highlighted content will have to be changed for your case. <?php $my_query = new WP_Query( array( ‘post_type’ => ‘company’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘service’, ‘field’ => ‘slug’, ‘terms’ => get_query_var( ‘service’ ), ), ), ‘paged’ => get_query_var(‘paged’, 1), ) );…
-

Remove Version Query String From Static JS And CSS Files
[ad_1] A website owner should always be trying to improve the speed of their website as much as possible. When you analyze your page using any page speed analyzer such as Page Speed, YSlow or Pingdom, you are very likely to see suggestions to remove query strings from static resources, such as Stylesheets and JavaScript…
-

Sort WordPress Posts With Multiple Criteria
[ad_1] By OutsourcedContent — on December 10, 2017 This was a case on a project where a custom listing post type had post meta that specified if it was as platinum sponsor, or a gold sponsor or a verified profile. The job was to list the platinum sponsors at the top on the archive page,…
-

Easy Tabbed Navigation With jQuery
[ad_1] By OutsourcedContent — on December 10, 2017 Here is the HTML Markup <h4 class=”single-company-tab-wrapper hide-if-no-js”> <a class=”single-company-tabs” href=”#info”>Info</a> <a class=”single-company-tabs” href=”#contact”>Contact</a> </h4> <div id=”info” class=”tab-content”> <p>Content of info tab</p> </div> <div id=”contact” class=”tab-content”> <p>Content of contact tab</p> </div> And here is the jQuery jQuery( document ).ready( function($){ $(‘.tab-content’).hide(); // Hide all tabs…
-

Add Custom Image Sizes Into WordPress Media Library
[ad_1] In a previous article we have posted about how you can define new custom image sizes to use on your WordPress theme and how to remove default image sizes. You can define and add custom image sizes with the help of add_image_size() function in WordPress. In this article we will show you how you…
-

Debugging WordPress With error_log()
[ad_1] By OutsourcedContent — on January 6, 2018 If Debug logging is enabled, simply use the error_log() function and it will be written to /wp-content/debug.log . Refer this article to see how it can be done: Enable Debug Logging In WordPress You can also write the error_log to a file. WP_DEBUG need not be set…
-

Full Width Responsive WordPress YouTube Embeds Automatically
[ad_1] By OutsourcedContent — on January 12, 2018 Add this to the functions.php /** * Add Response code to video embeds in WordPress * * @refer http://alxmedia.se/code/2013/10/make-wordpress-default-video-embeds-responsive/ */ function abl1035_alx_embed_html( $html ) { return ‘<div class=”video-container”>’ . $html . ‘</div>’; } add_filter( ’embed_oembed_html’, ‘abl1035_alx_embed_html’, 10, 3 ); add_filter( ‘video_embed_html’, ‘abl1035_alx_embed_html’ ); // Jetpack Add this…
-

Add Left And Right Swipe On Mobile For Bootstrap 4 Carousel
[ad_1] By OutsourcedContent — on January 13, 2018 We are talking about carousel included in Bootstrap 4, you can see how to add one here. Add this to your JS file or load it on the footer // Thanks to Maaaaark – https://github.com/maaaaark/bcSwipe/blob/master/jquery.bcSwipe.min.js !function(t){t.fn.bcSwipe=function(e){var n={threshold:50};return e&&t.extend(n,e),this.each(function(){function e(t){1==t.touches.length&&(u=t.touches[0].pageX,c=!0,this.addEventListener(“touchmove”,o,!1))}function o(e){if(c){var o=e.touches[0].pageX,i=u-o;Math.abs(i)>=n.threshold&&(h(),t(this).carousel(i>0?”next”:”prev”))}}function h(){this.removeEventListener(“touchmove”,o),u=null,c=!1}var u,c=!1;”ontouchstart”in document.documentElement&&this.addEventListener(“touchstart”,e,!1)}),this}}(jQuery); // Swipe…
-

Redirect User To Post If Search Results Return One Post
[ad_1] Recently on a project, my client asked me to develop a system to redirect user to post if search results returns only one post. Although it’s fairly simple system to develop but I started searching on Google if someone has already tried to develop similar function. Fortunately WordPress developer Paul Underwood has shared a…