Skip to content

Instantly share code, notes, and snippets.

View talentedaamer's full-sized avatar
🎯
WordPress, Laravel, JavaScript, Angular

Aamer Shahzad talentedaamer

🎯
WordPress, Laravel, JavaScript, Angular
View GitHub Profile
@talentedaamer
talentedaamer / gist:a623f5e09a21ce9f7af8
Last active November 26, 2015 04:56
Registering Properties Custom Post type with key "properties" and custom taxonomy with key "property-category"
<?php
/**
* Properties Post Type General Class
* @author Aamer
*
*/
class properties_cpt {
function properties_cpt() {
add_action( 'init', array( $this, 'create_property_cpt' ) );
@talentedaamer
talentedaamer / gist:68bccfe45eae395cd9c9
Created November 25, 2015 08:31
Register widget areas or sidebars in WordPress using register_sidebar() function
<?php
/**
* widgets_init action hook.
* used to register, widgets or widget areas in a theme.
*/
add_action( 'widgets_init', 'oopthemes_widgets_init' );
function oopthemes_widgets_init() {
register_sidebar( array(
'name' => __( 'Primary Sidebar', 'theme-slug' ),
'id' => 'sidebar-primary',
@talentedaamer
talentedaamer / gist:72f5c4ed64912fa7aaf4
Created November 25, 2015 08:06
Generate Unlimited Sidebars using this array()
<?php
/**
* list of sidebars to be generated
* @var array : array of sidebars
*/
$sidebars = array(
'footer one sidebar',
'footer two sidebar',
'footer three sidebar',
'footer four sidebar',
@talentedaamer
talentedaamer / gist:9aeb1fc2f738bcb68f32
Last active November 25, 2015 08:06
Generate Unlimited Sidebars/Widget Areas using a single array();
<?php
/**
* theme widgets and widget areas
*/
add_action ( 'widgets_init', 'oopthemes_register_sidebar' );
function oopthemes_register_sidebar( $sidebars = array() ) {
foreach ( $sidebars as $name ) {
/**
* sidebar name, make the words uppercase
* @var string : each name of the sidebar in the array
@talentedaamer
talentedaamer / gist:81574d819c34fe3fd2de
Last active November 24, 2015 11:35
Right way to use <title> tags in WordPress themes. add_theme_support( 'title-tag' );
<?php
/*
* call the oopthemes_after_setup function when theme is initialized.
*/
add_action( 'after_setup_theme', 'oopthemes_after_setup' );
function oopthemes_after_setup() {
/**
* Add support for the <title> tags.
* @since WordPress 4.1