Skip to content

Instantly share code, notes, and snippets.

View ernilambar's full-sized avatar

Nilambar Sharma ernilambar

View GitHub Profile
@ernilambar
ernilambar / wordpress_loop.php
Last active January 29, 2016 06:21
Alternative WordPress Loop Example
<?php
$custom_query_args = array(
'post_type' => 'post',
);
// Get current page and append to custom query parameters array
$custom_query_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$custom_query = new WP_Query( $custom_query_args ); ?>
<?php
// Pagination fix
@ernilambar
ernilambar / transient_example.php
Last active July 17, 2017 06:05
WordPress Transient Example
<?php
function example_transient(){
$transient_key = 'my_unique_transient_key';
$transient_period = 24 * HOUR_IN_SECONDS;
$output = get_transient( $transient_key );
if ( false === $output ) {
$output = 'Hello World';
@ernilambar
ernilambar / featured.php
Created August 27, 2014 00:18
Example Page Template for showing featured posts [NS Featured Posts]
@ernilambar
ernilambar / author-box-snippet.php
Created February 1, 2015 14:31
author-box-snippet.php
<?php
add_action( 'blue_planet_author_box', 'custom_blue_planet_author_box' );
function custom_blue_planet_author_box(){
ob_start();
?>
<style>
.authorbox{
@ernilambar
ernilambar / dbtest.php
Last active November 9, 2015 08:14
Simple tool for testing MySQL database
<?php
/**
* Simple tool for testing MySQL database.
*
* @package DB_Test
* @author Nilambar Sharma <nilambar@outlook.com>
* @license GPL-2.0+
* @link http://www.nilambar.net
* @copyright 2015 Nilambar Sharma
*/
<?php
/**
* Plugin Name: Foo Single
* Plugin URI: https://example.com
* Description: Custom plugin.
* Version: 1.0.0
* Author: Nilambar Sharma
* Author URI: https://asdf.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt