Custom Recent Post Widget

<?php Class My_Recent_Posts_Widget extends WP_Widget_Recent_Posts { function widget($args, $instance) { extract( $args ); $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base); if( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) $number = 10; $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', … Continue reading Custom Recent Post Widget

Search Filter by post

/* Search Filter */ if (!is_admin()) { function wpb_search_filter($query) { if ($query->is_search) { $query->set('post_type', 'post'); } return $query; } add_filter('pre_get_posts','wpb_search_filter'); } /* End of Search Filter */

Add class to menu items of one specific menu or Current Menu

add_filter('nav_menu_css_class', 'springhomeshow_add_active_class', 10, 2 ); function springhomeshow_add_active_class($classes, $item) { if( $item->menu_item_parent == 0 && in_array( 'current-menu-item', $classes ) || in_array( 'current-menu-ancestor', $classes ) || in_array( 'current-menu-parent', $classes ) || in_array( 'current_page_parent', $classes ) || in_array( 'current_page_ancestor', $classes ) ) { $classes[] = "current"; } return $classes; }

wp-security

<?php // remove unnecessary header information function remove_header_info() { remove_action('wp_head', 'feed_links_extra', 3); remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'wp_generator'); remove_action('wp_head', 'start_post_rel_link'); remove_action('wp_head', 'index_rel_link'); remove_action('wp_head', 'parent_post_rel_link', 10, 0); remove_action('wp_head', 'adjacent_posts_rel_link_wp_head',10,0); // for WordPress >= 3.0 } add_action('init', 'remove_header_info'); // smart jquery inclusion if (!is_admin()) { wp_deregister_script('jquery'); wp_register_script('jquery', ("https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"), false); wp_enqueue_script('jquery'); } // remove wp version meta tag … Continue reading wp-security

jquery ajax form

jQuery(document).ready(function() { jQuery(".submit_customer_btn").click(function() { /**************** Register ***************************/ jQuery("#notic_add_customer.alert").hide(); //on focus jQuery("#add_customer_form .isrequired, #add_customer_form .isrequired").focus(function(){ jQuery(this).removeClass('error'); }); //on blur jQuery("#add_customer_form .isrequired, #add_customer_form .isrequired").blur(function() { if(jQuery(this).val().trim() == '') { jQuery(this).addClass('error'); } else { jQuery(this).removeClass('error'); } }); if(jQuery("#firstname").val().trim() == '' || jQuery("#lastname").val().trim() == '' || jQuery("#mobile").val().trim() == '' || jQuery("#email").val().trim() == '' || jQuery("#streetaddress1").val().trim() == '' || jQuery("#zip").val().trim() … Continue reading jquery ajax form

How to use custom metabox form and ajax

function.php add code <?php // Register Custom Post Type function custom_post_type_order_book() { $labels = array( 'name' => _x( 'Book Orders', 'Post Type General Name', 'text_domain' ), 'singular_name' => _x( 'Book Order', 'Post Type Singular Name', 'text_domain' ), 'menu_name' => __( 'Book Orders', 'text_domain' ), 'name_admin_bar' => __( 'Book Order', 'text_domain' ), 'archives' => __( 'Item … Continue reading How to use custom metabox form and ajax

How to create custom Widget for Custom Post Types

click here OR   class My_Widget extends WP_Widget { public function __construct() { $widget_ops = array('classname' => 'My_Widget', 'description' => 'Displays an My widget!' ); $this->WP_Widget('My_Widget', 'My widget', $widget_ops); } function widget($args, $instance) { // PART 1: Extracting the arguments + getting the values extract($args, EXTR_SKIP); $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); … Continue reading How to create custom Widget for Custom Post Types

Product inquiry woocommerce

<?php /* Plugin Name: Product inquire Version: 1.0 Author: Name Description: This pluging provide to product inquire */ function product_inquire_scripts() { wp_register_style( 'product-inquire-style', plugins_url('css/product-inquire.css', __FILE__) ); wp_enqueue_style( 'product-inquire-style' ); } add_action( 'wp_enqueue_scripts', 'product_inquire_scripts' ); /* Creating Menus */ function product_inquire_Menu() { /* Adding menus */ add_menu_page(__('Inquire List'),'Inquire List', 8,'proinq/inquirelist.php', 'inquire_list', "", 26); /* Adding Sub … Continue reading Product inquiry woocommerce