Skip to content

Instantly share code, notes, and snippets.

View humayunahmed8's full-sized avatar
🤡
code fool

Humayun Ahmed humayunahmed8

🤡
code fool
View GitHub Profile
<?php
/* Register custom post types on the 'init' hook. */
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 0.1.0
* @access public
@humayunahmed8
humayunahmed8 / custom-post-type.php
Created December 4, 2017 07:06
Register custom post type
// Register services custom post type
function service_post_type() {
$labels = array(
'name' => _x( 'Services', 'post type general name', 'your-plugin-textdomain' ),
'singular_name' => _x( 'Service', 'post type singular name', 'your-plugin-textdomain' ),
'menu_name' => _x( 'Services', 'admin menu', 'your-plugin-textdomain' ),
'name_admin_bar' => _x( 'Service', 'add new on admin bar', 'your-plugin-textdomain' ),
'add_new' => _x( 'Add New', 'Service', 'your-plugin-textdomain' ),
'add_new_item' => __( 'Add New Service', 'your-plugin-textdomain' ),
@humayunahmed8
humayunahmed8 / query_posts_type.php
Last active December 4, 2017 09:58
Querying by Post Type
<!-- Querying by Post Type -->
<section id="slider">
<?php
query_posts(array(
'post_type' => 'slider',
'post_per_page' => 1,
@humayunahmed8
humayunahmed8 / archive.php
Last active December 4, 2017 15:12
WP Archive Page Demo
<!-- call header -->
<?php get_header();?>
<!-- Blog title Section -->
<section id="heading">
<div class="overlay">
<div class="container">
<h1 class="title">Blog</h1>
@humayunahmed8
humayunahmed8 / custom_widget.php
Last active December 7, 2017 09:42
Register custom widget and sidebar
<?php
// Register right sidebar
function footer_widget(){
register_sidebar(array(
'name'=>'Footer Sidebar',
'id'=>'footer_widget',
'description'=>'This is our footer widget',
@humayunahmed8
humayunahmed8 / custom-meta-box.php
Last active December 7, 2017 09:45
Register custom meta boxes
// Register a meta box under the services section
function service_meta_box() {
add_meta_box(
'service_icon',//id
'Service Metabox',//title
'service_icon_callback',//callback
'service',//screen
'side',//context
'high'//priority
@humayunahmed8
humayunahmed8 / setting_api.php
Last active December 8, 2017 05:26
Add WP Setting API
// WP setting API (use for all section heading and short desription)
function wp_option_field(){
//add_settings_field( $id, $title, $callback, $page, $section = 'default', $args = array() )
add_settings_field( 'service_title', 'Service Title', 'service_title_callback' , 'general' );
add_settings_field( 'service_des', 'Service Descriptin', 'service_des_callback' , 'general' );
add_settings_field( 'our_team_title', 'Team Title', 'our_team_title_callback' , 'general' );
@humayunahmed8
humayunahmed8 / wpwidget_api.php
Created December 8, 2017 05:30
WP Widget API
// WP widget API (collected from codex documentation)
<?php
/**
* Adds Foo_Widget widget.
*/
class Foo_Widget extends WP_Widget {
/**
@humayunahmed8
humayunahmed8 / searchbar_ex.php
Last active December 8, 2017 05:42
Dynamic Searchbar
// Dynamic search bar (searchform.php).
<!-- Search Bar -->
<div class="widget blog-search-bar">
<h4 class="title">Search</h4>
<form class="form-search" method="get" id="s" action="<?php bloginfo('url'); ?>/">
<div class="input-append">
<input class="form-control input-medium search-query" type="text" name="s" value="<?php the_search_query(); ?>" placeholder="Search" required>
<button class="add-on" type="submit"><i class="fa fa-search"></i></button>
@humayunahmed8
humayunahmed8 / 404.css
Last active December 8, 2017 05:57
WP 404!! Page
/* -404 Page CSS
-------------------------------------------------------------------------*/
.wrap {
font-family: 'Open Sans', sans-serif;
-webkit-background-size:cover;
-moz-background-size:cover;
background-size:cover;
background-attachment: fixed;
height: 100%;
display: flex;