Remove Auto Suggestion of Form Fields

HTML Way


<input type="text" autocomplete="off" >

jQuery:


$('input[type="text"]').attr('autocomplete','off');

Advertisements

Audio Player Shortcode

Continue reading “Audio Player Shortcode”

Separate Search Page for Post Type Wp

Paste this code on top of search.php

Create New File like “search-postTypeName.php”


$post_type = $_GET['post_type'];

if ( isset( $post_type ) && locate_template( 'search-' . $post_type . '.php' ) ) {
  // if so, load that template
  get_template_part( 'search', $post_type );
  
  // and then exit out
  exit;
}

Wp Custom Search Form

Search Filter with input hidden fields

<form method="get" action="<?php bloginfo('url'); ?>/">
    <label for="s">Search the site: </label>
    <input type="text" id="s" name="s" value="<?php the_search_query(); ?>">
 
    <!-- Search only these custom post types -->
    <input type="hidden" name="post_type[]" value="page">
    <input type="hidden" name="post_type[]" value="services">
    <input type="hidden" name="post_type[]" value="solutions">

    <!-- Search only this cat with value of 22 -->
    <input type="hidden" value="22" name="cat" id="scat" />

    <input type="submit" value="Search">
</form>

WP Query Arguments

Codex:
http://codex.wordpress.org/Class_Reference/WP_Query#Parameters

Author Parameters – Show posts associated with certain author.
http://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters


$args = array(

    // (int) - use author id [use minus (-) to exclude authors by ID ex. 'author' => '-1,-2,-3,']
    'author' => '1,2,3,',
	
	//(string) - use 'user_nicename' (NOT name)
    'author_name' => 'speedy',       
	
	//(array) - use author id (available with Version 3.7).
    'author__in' => array( 2, 6 ),            
	
	//(array)' - use author id (available with Version 3.7).
    'author__not_in' => array( 2, 6 ),    
   

 

Category Parameters – Show posts associated with certain categories.
http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
Continue reading “WP Query Arguments”

Change Images According Resolution

<picture>
    <source media="(min-width: 1200px)"
        srcset="https://picsum.photos/1200/300?image=0">
    <source media="(min-width: 900px)"
        srcset="https://picsum.photos/900/300?image=2">
    <img src="https://picsum.photos/300/300?image=0">
</picture>

Example

Toggling More Than Two Classes


<div class="box">A</div>


<div class="box">B</div>

 

Calling Function on Click

$('.box').on('click', e => {
  $(e.target).toggleClasses([
    'myClass1',
    'myClass2',
    'myClass3',
    'myClass4'
  ], true);
});

 

Main Function

$(function(e) {
  e.fn.extend({
    toggleClasses: function(t, r) {
      var o = {
          toggleZero: r
        },
        n = 0,
        s = e(this).attr("class").split(" "),
        i = [];
      Array.prototype.remove = function() {
        for (var e, t, r = arguments, o = r.length; o && this.length;)
          for (e = r[--o]; - 1 !== (t = this.indexOf(e));) this.splice(t, 1);
        return this
      };
      for (var u = 0; u < t.length; u++) - 1 != s.indexOf(t[u]) && (i[u] = "true");
      for (var a = 0; a < t.length; a++) { if (!(i.indexOf("true") >= 0)) {
          n = 0, s.push(t[n]);
          break
        }
        if ("true" === i[a] && a < t.length - 1) { s.remove(t[a]), n = a + 1, s.push(t[n]); break } if ("true" === i[a]) { s.remove(t[a]), n = 0, t.length > 1 && o.toggleZero !== !0 && s.push(t[n]);
          break
        }
      }
      return e.extend(o, t), e(this).each(function() {
        e(this).attr("class", s.join(" "))
      })
    }
  });
});

Example