Skip to content

Instantly share code, notes, and snippets.

Avatar
🤡
code fool

Humayun Ahmed humayunahmed8

🤡
code fool
View GitHub Profile
View register-post-type.php
<?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
View custom-post-type.php
// 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' ),
View query_posts_type.php
<!-- Querying by Post Type -->
<section id="slider">
<?php
query_posts(array(
'post_type' => 'slider',
'post_per_page' => 1,
@humayunahmed8
humayunahmed8 / archive.php
Last active Dec 4, 2017
WP Archive Page Demo
View archive.php
<!-- 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 Dec 7, 2017
Register custom widget and sidebar
View custom_widget.php
<?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 Dec 7, 2017
Register custom meta boxes
View custom-meta-box.php
// 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
View setting_api.php
// 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' );
View wpwidget_api.php
// WP widget API (collected from codex documentation)
<?php
/**
* Adds Foo_Widget widget.
*/
class Foo_Widget extends WP_Widget {
/**
View searchbar_ex.php
// 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>
View 404.css
/* -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;