Skip to content

Instantly share code, notes, and snippets.

View shahadat014's full-sized avatar

Md.Shahadat Hossen shahadat014

  • ACS TEXTILES BD LTD.
  • Rupganj, Narayanganj, Dhaka
  • 00:55 (UTC +06:00)
View GitHub Profile
@shahadat014
shahadat014 / wordpress code
Last active August 29, 2015 14:13
Register option tree metabox
function my_theme_custom_meta_boxes() {
$post_meta_box = array(
'id' => 'post_meta_box',
'title' => 'Metabox',
'pages' => array( 'post' ),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 16:34
How to activate option tree in wordpress theme
add_filter( 'ot_show_pages', '__return_false' );
add_filter( 'ot_show_new_layout', '__return_false' );
add_filter( 'ot_theme_mode', '__return_true' );
include_once( 'option-tree/ot-loader.php' );
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 18:36
Option tree demo theme option
<?php
add_action( 'admin_init', 'my_theme_custom_theme_options', 1 );
function my_theme_custom_theme_options() {
$saved_settings = get_option( 'option_tree_settings', array() );
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 18:41
WordPress image crop
add_theme_support( 'post-thumbnails');
WordPress crop an image = 5 size. Sizes are given below
thumbnail: Thumbnail (default 150px x 150px max)
medium: Medium resolution (default 300px x 300px max)
large: Large resolution (default 640px x 640px max)
full: Original image resolution (unmodified)
But, if you need custom size, you can define sizes in functions.php
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 18:50
Custom post loop with custom fields
<?php
global $post;
$args = array( 'posts_per_page' => -1, 'post_type'=> 'posttype', 'orderby' => 'menu_order', 'order' => 'ASC' );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<?php
$job_link= get_post_meta($post->ID, 'job_instructions', true);
?>
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 18:53
Enable masonry in WordPress
add_action( 'wp_enqueue_scripts', 'jk_masonry' );
function jk_masonry() {
wp_enqueue_script( 'jquery-masonry', array( 'jquery' ) );
}
How to use?
$('#container').masonry({ singleMode: true });
or
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 18:55
Shortcode inside custom post wordpress
function post_list_shortcode($atts){
extract( shortcode_atts( array(
'count' => '',
), $atts) );
$q = new WP_Query(
array('posts_per_page' => $count, 'post_type' => 'posttype', 'meta_key' => 'order_number','orderby' => 'meta_value','order' => 'ASC')
);
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 19:00
Homepage/Front page only conditional code wordpress
Homepage only data with default data
<?php if( is_home() || is_front_page() ) : ?>
<!-- Homepage Only Code -->
<?php else : ?>
<!-- Other Page Code -->
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 19:01
Infinite animated.css in Owl Carousel
jQuery(".all_slides").owlCarousel({
singleItem: true,
pagination: false,
autoPlay: 5000,
theme: "homepage-slider-arrows",
navigation: true,
addClassActive: true,
transitionStyle : "fade",
navigationText: ["<i class='fa fa-angle-left'></i>","<i class='fa fa-angle-right'></i>"],
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 19:02
Custom post query with pagination
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('showposts=6&post_type=posttype&orderby=menu_order&order=ASC'.'&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>