Skip to content

Instantly share code, notes, and snippets.

View dasbairagya's full-sized avatar
🎯
Focusing

Gopal Dasbariagya dasbairagya

🎯
Focusing
View GitHub Profile
@dasbairagya
dasbairagya / tab.html
Created June 11, 2018 09:23
bootstrap-keep-last-selected-tab-active-on-page-refresh
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Keep Last Selected Bootstrap Tab Active on Page Refresh</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
@dasbairagya
dasbairagya / functions.php
Last active July 5, 2018 04:36
How to fetch the popular post in wordpress according to views
<?php
/* for popular post*/
/* set the post view count*/
function wpb_set_post_views($postID) {
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
@dasbairagya
dasbairagya / search.php
Created April 9, 2018 10:16
WP Custom Search
<?php
/**
* Template Name: Search1
*/
get_header(); ?>
<form id="searchform" action="" method="get">
<input class="" type="text" name="serchprm" id="searchinput" placeholder="Search">
@dasbairagya
dasbairagya / contact.php
Created April 4, 2018 10:56
wordpress common contact form for contact form 7
<div class="row">
<div class="form-group col-md-12 custom-form">
[text* name id:name class:form-control placeholder "Your Name"]
</div>
<div class="form-group col-md-12 custom-form">
[email* email id:email class:form-control placeholder "Your E-mail"]
</div>
<div class="form-group col-md-12 custom-form">
@dasbairagya
dasbairagya / paging.php
Created April 4, 2018 06:58
Custom php pagination in wordpress
<?php
<style type="text/css">
select.sts_width {
width: 75%;
}
.loader{
display: none;
}
/* Pagination links */
.pagination a {
@dasbairagya
dasbairagya / functions.php
Last active July 8, 2020 15:00
Add login button for beside add to cart for logout user
<?php
function wishlist_check(){
if(!is_user_logged_in()){
echo '<a class="woo-login-popup-sc-open">Login</a>';
}
}
add_action('woocommerce_single_product_summary','wishlist_check',30);
@dasbairagya
dasbairagya / functions.php
Last active July 5, 2018 04:40
Customize woocommerce default sorting
<?php
function patricks_woocommerce_catalog_orderby( $orderby ) {
unset($orderby["menu_order"]);
unset($orderby["popularity"]);
unset($orderby["rating"]);
return $orderby;
}
add_filter( "woocommerce_catalog_orderby", "patricks_woocommerce_catalog_orderby", 20 );
function patricks_woocommerce_catalog_orderby1( $orderby ) {
$orderby["date"] = __('Sort by date: newest to oldest', 'woocommerce');
@dasbairagya
dasbairagya / funations.php
Last active July 5, 2018 04:41
Changing the Entry Title of the Custom Endpoint
<?php
function wpb_woo_endpoint_title( $title, $id ) {
if ( is_wc_endpoint_url( 'edit-address' ) && in_the_loop() ) { // add your endpoint urls
$title = "Address Book"; // change your entry-title
}
elseif ( is_wc_endpoint_url( 'orders' ) && in_the_loop() ) {
$title = "My Orders";
}
elseif ( is_wc_endpoint_url( 'edit-account' ) && in_the_loop() ) {
$title = "Account Information";
@dasbairagya
dasbairagya / fucntions.php
Last active July 5, 2018 04:42
Modification of navigation menu on my account page in woocommerce
<?php
//modification of navigation menu on my account page
// Note the low hook priority, this should give to your other plugins the time to add their own items...
add_filter( 'woocommerce_account_menu_items', 'add_my_menu_items', 99, 1 );
function add_my_menu_items( $items ) {
$my_items = array(
// endpoint => label
'edit-account' => __( 'Account Information', 'my_plugin' ),
'orders' => __( 'My Orders', 'my_plugin' ),
'wishlist' => __( 'My Wishlist', 'my_plugin' ),
@dasbairagya
dasbairagya / functions.php
Last active July 5, 2018 04:43
Woocommerce shop shop details page customizations using hook:
<?php
/* woocommerce customization*/
add_filter( 'woocommerce_show_page_title' , 'woo_hide_page_title' );
function woo_hide_page_title() {
return false;
}
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
//remove the sale flush
remove_action('woocommerce_before_shop_loop_item_title','woocommerce_show_product_loop_sale_flash',10);
//add the custom icon div after thumbnail