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 / jQuery-autocomplete.php
Last active January 2, 2017 05:36
JQuery autocomplete input-field by term-taxonomy.
<?php
/**
* Template Name: Test
* Created by PhpStorm.
* User: PC35
* Date: 23-12-2016
* Time: 10:32
*/
?>
@dasbairagya
dasbairagya / front-end-to-cpt.php
Created December 27, 2016 06:46
How to add post from front-end form to custom post type in admin back-end
<?php
/**
* template name: blogupdate
* Created by PhpStorm.
* User: PC35
* Date: 25-10-2016
* Time: 16:04
*/
global $wpdb;
$id= get_current_user_id();
@dasbairagya
dasbairagya / live-templates.php
Last active January 2, 2017 12:54
Phpstrom live templates
Abbreviation: cpt
Description: custom post type
<?php
/**
* Register Post Type $cpt$
*/
add_action( 'init', 'codex_$cpt$_init' );
function codex_$cpt$_init() {
@dasbairagya
dasbairagya / file_upload.php
Last active January 20, 2017 21:34
Custom plugin for file upload and view
<?php
/*
Plugin Name: CV
Plugin URI: http://Gowebbi.com/
Description: CV
Author:
Version: 1.0
Author URI: http://Gowebbi.com/
*/
add_action('admin_menu', 'wp_show_summery');
@dasbairagya
dasbairagya / delete.php
Last active March 8, 2022 07:28
Delete a table-row using JQuery Ajax without page reload
<?php
/**
* Template Name: Delete
* Created by PhpStorm.
* User: PC35
* Date: 30-12-2016
* Time: 18:21
*/
global $wpdb;
if(isset($_POST['delete_row']))
@dasbairagya
dasbairagya / posts.php
Created January 2, 2017 13:18
get a list of posts from Custom Taxonomy
<?php
$terms = get_terms( array(
'taxonomy' => 'taxonomy_name',
'hide_empty' => false,
) );
//from the above code you will get the term id;
$args = array(
'post_type' => 'product',
@dasbairagya
dasbairagya / functions.php
Last active September 8, 2017 12:53
Wordpress pagination for custom post type
//Add this pice of code to functions.php
<?php
require_once('wp_bootstrap_pagination.php');
function customize_wp_bootstrap_pagination($args) {
$args['previous_string'] = 'previous';//customize according to your class
$args['next_string'] = 'next';//customize according to your class
return $args;
@dasbairagya
dasbairagya / form.html
Last active January 9, 2017 12:29
Submit html form using Ajax with loader
<html>
<head>
<title>Insert data in the database using Ajax</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<style>/* Absolute Center Spinner */
.success{
color:green;
font-size:20px;
border:1px solid green;
padding: 8px;
@dasbairagya
dasbairagya / functions.php
Last active April 27, 2017 09:43
Dynamic menu creation using walker
<?php
include('walker.php');
function create_menu(){
register_nav_menu('primary','Main-Menu');
register_nav_menu('secondary','Footer Menu');
}
add_action('init','create_menu');
?>
?>
@dasbairagya
dasbairagya / index.php
Last active January 20, 2017 21:28
Dynamically create active class within loop
<div class="carousel-inner" role="listbox">
<?php
$c = 0;
$class = '';
query_posts('category_name=slider&showposts=3');
if ( have_posts() ) : while ( have_posts() ) : the_post();
$c++;
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail' );