Skip to content

Instantly share code, notes, and snippets.

View tanjilahmed7's full-sized avatar

Tanjil Ahmed tanjilahmed7

View GitHub Profile
@tanjilahmed7
tanjilahmed7 / example-wp-list-table.php
Created July 15, 2019 17:56 — forked from paulund/example-wp-list-table.php
An example code of using the WP_List_Table class. With Pagination.
<?php
/*
* Plugin Name: Paulund WP List Table Example
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area
* Plugin URI: http://www.paulund.co.uk
* Author: Paul Underwood
* Author URI: http://www.paulund.co.uk
* Version: 1.0
* License: GPL2
*/
function paginglink($query,$records_per_page)
{
$self = $_SERVER['PHP_SELF'];
$stmt = $this->conn->prepare($query);
$stmt->execute();
$total_no_of_records = $stmt->rowCount();
$total_no_of_pages = ceil($total_no_of_records / $records_per_page);
if (!empty($_GET['page_no'])) {
$page = $_GET['page_no'];
@tanjilahmed7
tanjilahmed7 / index.php
Created September 4, 2016 16:26
Generate Random
<?php
function abc()
{
$a = array();
while (true)
{
$r = rand(1, 15);
@tanjilahmed7
tanjilahmed7 / content.php
Created January 16, 2016 11:02
taxonomy
<?php
//get all categories then display all posts in each term
$taxonomy = 'std_class_txonomy';
$param_type = 'category__in';
$term_args=array(
'orderby' => 'id',
'order' => 'asc'
);
$terms = get_terms($taxonomy,$term_args);
@tanjilahmed7
tanjilahmed7 / wp-devs.php
Last active November 30, 2015 11:00
Let’s make a WordPress Widget that displays our Custom Post Types
<?php
//custom widget tutorial
class Realty_Widget extends WP_Widget
{
function __construct() {
parent::__construct(
'realty_widget', // Base ID
'Notice Widget', // Name
array('description' => __( 'Displays your latest listings. Outputs the post thumbnail, title and date per listing'))
);
@tanjilahmed7
tanjilahmed7 / functions.php
Last active January 2, 2020 09:23
Shortcode API
<?php
/*
Shortcode Making By: Tanjil Ahmed
PurpleIT
*/
//Shortcode
function box($atts, $content = null) {
ob_start();
@tanjilahmed7
tanjilahmed7 / Options Framework.txt
Last active September 16, 2015 10:17
Condtional field using in SMOF Options Framework
Custom Background Function
==============================================================================
$of_options[] = array( "name" => "Background Images",
"desc" => "Select a background pattern.",
"id" => "custom_bg",
"std" => $bg_images_url."bg0.png",
"type" => "tiles",
"options" => $bg_images,
@tanjilahmed7
tanjilahmed7 / themes-template.php
Created September 13, 2015 10:44
Structure of the Loop
<?php
$args = array(
// Arguments for your query.
);
// Custom query.
$query = new WP_Query( $args );
// Check that we have query results.
@tanjilahmed7
tanjilahmed7 / functions.php
Created September 10, 2015 11:12
Wordpress Custom Post -> Meta Box
<?php
// Add the Meta Box
function add_custom_meta_box() {
add_meta_box(
'custom_meta_box', // $id
'Author', // $title
'show_custom_meta_box', // $callback
'post', // $page
'normal', // $context
'high'); // $priority
@tanjilahmed7
tanjilahmed7 / responsive.html
Created August 23, 2015 12:21
Responsive Meida Qurey's
/* Medium Layout: 1280px. */
@media only screen and (min-width: 992px) and (max-width: 1200px) {
}
/* Tablet Layout: 768px. */
@media only screen and (min-width: 768px) and (max-width: 991px) {
}