Last active
August 29, 2015 14:19
-
-
Save hemusyl/ebd9ad47f36596507a1b to your computer and use it in GitHub Desktop.
Dhaka-wp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
---------------------------------------------------------- | |
For style css | |
/* | |
Theme Name: Payra TV | |
Theme URI: http://www.payratv.com | |
Author: Humayun Kabir | |
Author URI: http://www.hkfolio.com/ | |
Description: This theme created for payratv. | |
Version: 1.0 | |
Tags: black, brown, orange, tan, white, yellow, light, one-column, two-columns, right-sidebar, flexible-width, custom-header, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, translation-ready | |
Text Domain: payratv | |
*/ | |
================================================================== | |
//Responsive codepress_supported_langs/* Tablet Layout: 768px. */ | |
@media only screen and (min-width: 768px) and (max-width: 991px) { | |
} | |
/* Mobile Layout: 320px. */ | |
@media only screen and (max-width: 767px) { | |
} | |
/* Wide Mobile Layout: 480px. */ | |
@media only screen and (min-width: 480px) and (max-width: 767px) { | |
} | |
================================================================================== | |
<html lang="en"> | |
= <html <?php language_attributes(); ?>> | |
<meta charset="utf-8"> | |
= <meta charset="<?php bloginfo( 'charset' ); ?>" /> | |
<title>Moderna - Bootstrap 3 flat corporate template</title> | |
= <title><?php wp_title( '|', true, 'right' ); ?><?php bloginfo('name'); ?></title> | |
// Favicon | |
<link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/images/icons/favicon.png" /> | |
For responsive | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> | |
Logo Image linking with home or front page | |
=> <a href="<?php echo site_url(); ?>"><img src="<?php echo get_template_directory_uri(); ?>/img/payranb.png" alt=""></a> | |
Meta rakhar projon nai, egulu WP SEO code theke asbe | |
<?php wp_enqueue_style( $handle, $src, $deps, $ver, $media ); ?> | |
Functions php te stylsheet call korte hobe | |
<?php | |
function my_function_name(){ | |
// Style CSS | |
wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '3.1.0', 'all'); | |
wp_enqueue_style('style', get_stylesheet_uri()); | |
//Adding "Bitter" google fonts | |
wp_enqueue_style( 'et-googleFonts', 'http://fonts.googleapis.com/css?family=Bitter:400,400italic,700'); | |
// jQuery call | |
wp_enqueue_script('jquery'); | |
wp_enqueue_script('easing', get_template_directory_uri() . '/js/jquery.easing.1.3.js',array('jquery'), '1.3.0', TRUE); | |
wp_enqueue_script('bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '3.1.0', TRUE); | |
} | |
add_action('wp_enqueue_scripts', 'my_fuction_name'); | |
© 2013 -<?php echo date('Y'); ?> | |
============================== | |
<?php wp_head(); ?> </head> er age | |
<?php wp_footer(); ?> </body> er age | |
================================ | |
<img src="img/Koala.jpg" alt=""> | |
= <?php echo get_template_directory_uri(); ?>/ | |
========================= | |
<?php get_header(); ?> | |
<?php get_footer(); ?> | |
// add menu support and fallback menu if menu doesn't exist | |
add_action('init', 'hk_register_menu'); | |
function hk_register_menu() { | |
if (function_exists('register_nav_menu')) { | |
register_nav_menu( 'main-menu', __( 'Main Menu' ) ); | |
register_nav_menu( 'footer-menu', __( 'Footer Menu' ) ); | |
} | |
} | |
function hk_default_menu() { | |
echo '<ul class="nav navbar-nav">'; | |
if ('page' != get_option('show_on_front')) { | |
echo '<li><a href="'. site_url() . '/">Home</a></li>'; | |
} | |
wp_list_pages('title_li='); | |
echo '</ul>'; | |
} | |
// headea.php ei code bosbe | |
<?php | |
if (function_exists('wp_nav_menu')) { | |
wp_nav_menu(array('theme_location' => 'main-menu', | |
'menu_class' => 'nav navbar-nav', | |
'fallback_cb' => 'hk_default_menu', | |
)); | |
} | |
else { | |
hk_default_menu(); | |
} | |
?> | |
============================================================================ | |
<!-- Theme supports --> | |
add_theme_support( 'html5', array( | |
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' | |
) ); | |
/* | |
* Enable support for Post Formats. | |
* | |
* See: https://codex.wordpress.org/Post_Formats | |
*/ | |
add_theme_support( 'post-formats', array( | |
'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat' | |
) ); | |
// Enabling Support for Post Thumbnails | |
add_theme_support( 'post-thumbnails' ); | |
// Add default posts and comments RSS feed links to head. | |
add_theme_support( 'automatic-feed-links' ); | |
/* | |
* Let WordPress manage the document title. | |
* By adding theme support, we declare that this theme does not use a | |
* hard-coded <title> tag in the document head, and expect WordPress to | |
* provide it for us. | |
*/ | |
add_theme_support( 'title-tag' ); | |
add_filter('widget_text', 'do_shortcode'); | |
============================================================================= | |
//widget register | |
function hk_widget_areas() { | |
register_sidebar( array( | |
'name' => __( 'Live Video', 'bilanti' ), | |
'id' => 'livevideo', | |
'description' => 'For Footer Area', | |
'before_widget' => '<div class="embed-responsive embed-responsive-16by9">', | |
'after_widget' => '</div>', | |
'before_title' => '<p class="video-head">', | |
'after_title' => '</p>', | |
) ); | |
} | |
add_action('widgets_init', 'hk_widget_areas'); | |
-------------------- | |
ar jekhane widget bosbe sekhane likhte hobe | |
<?php dynamic_sidebar('livevideo'); ?> | |
// Condition | |
<?php if(is_active_sidebar('livevideo')): ?> | |
<?php dynamic_sidebar('livevideo'); ?> | |
<?php endif; ?> | |
- --------- ------------------------- | |
<?php if( !dynamic_sidebar('footer_four')): ?> | |
<?php dynamic_sidebar('footer_three'); ?> | |
<?php endif; ?> | |
--------------------------------- | |
<div id="footer-sidebar" class="secondary"> | |
<div id="footer-sidebar1"> | |
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(2) ) : ?> | |
<?php endif; ?> | |
</div> | |
<div id="footer-sidebar2"> | |
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(3) ) : ?> | |
<?php endif; ?> | |
</div> | |
============================================================== | |
//Nivo slider | |
//Ei code tuke jekhane slider HTMl ache sekhane bosate hobe orthat img gulu tulte hobe | |
// <img src="" alt=""> | |
------------------------------------------ | |
<?php query_posts(array( | |
'post_type' => 'slide', // egulu $args | |
'posts_per_page' => 10, | |
) ); ?> | |
<?php while ( have_posts() ) : the_post(); ?> | |
<?php the_post_thumbnail('slide-image'); ?> | |
<?php endwhile; ?> | |
<?php wp_reset_query(); ?> | |
=========================== Or nicer code ============================== | |
<?php | |
$args = array( 'post_type' => 'slide', 'posts_per_page' => 10 ); | |
$loop = new WP_Query( $args ); | |
?> | |
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?> | |
<?php the_post_thumbnail('slide-image'); ?> | |
<?php the_title(); ?> | |
<?php the_excerpt(); ?> | |
<?php endwhile; ?> | |
<?php wp_reset_query(); ?> | |
-------------------------------------------------- | |
<?php | |
$images = get_field('images'); | |
if( $images ): ?> | |
<div id="slider" class="flexslider"> | |
<ul class="slides"> | |
<?php foreach( $images as $image ): ?> | |
<li> | |
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /> | |
<p><?php echo $image['caption']; ?></p> | |
</li> | |
<?php endforeach; ?> | |
</ul> | |
</div> | |
<?php endif; ?> | |
============================================================= | |
functions.php te likhte hobe othoba custom-posts.php | |
<?php add_image_size( $name, $width, $height, $crop ); ?> | |
image support and crop er jonno | |
add_theme_support('post-thumbnails'); | |
add_image_size('slide-image',750,300,true); | |
========================================================================= | |
custome post functions.php te or custom-post.php likhte hobe | |
<?php | |
function payra_theme_custom_posts(){ | |
register_post_type('slide', | |
array( | |
'labels' => array( | |
'name' => __('Slides'), | |
'singular_name' => __('slide'), | |
'all_items' => __( 'All Slides' ), | |
'add_new' => __( 'Add New Slide'), | |
'edit_item' => __( 'Edit Slide' ), | |
), | |
'public' => true, | |
'has_archive' => true, | |
'menu_icon' => 'dashicons-slides', //http://www.kevinleary.net/wordpress-dashicons-list-custom-post-type-icons/ | |
'supports' => array( 'title', 'editor', 'thumbnail','excerpt','custom-fields' ), | |
)); | |
} | |
add_action('init','payra_theme_custom_posts'); | |
--------------------------------------------------- | |
//Tuts http://code.tutsplus.com/tutorials/a-guide-to-wordpress-custom-post-types-creation-display-and-meta-boxes--wp-27645 | |
function create_movie_review() { | |
register_post_type( 'movie_reviews', | |
array( | |
'labels' => array( | |
'name' => 'Movie Reviews', | |
'singular_name' => 'Movie Review', | |
'add_new' => 'Add New', | |
'add_new_item' => 'Add New Movie Review', | |
'edit' => 'Edit', | |
'edit_item' => 'Edit Movie Review', | |
'new_item' => 'New Movie Review', | |
'view' => 'View', | |
'view_item' => 'View Movie Review', | |
'search_items' => 'Search Movie Reviews', | |
'not_found' => 'No Movie Reviews found', | |
'not_found_in_trash' => 'No Movie Reviews found in Trash', | |
'parent' => 'Parent Movie Review' | |
), | |
'public' => true, | |
'menu_position' => 15, | |
'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' ), | |
'taxonomies' => array( '' ), | |
'menu_icon' => plugins_url( 'images/image.png', __FILE__ ), | |
'has_archive' => true | |
) | |
); | |
} | |
add_action( 'init', 'create_movie_review' ); | |
========================================================== | |
<div class="item"> <?php the_post_thumbnail('carusel-image'); ?></div> | |
==================================================== | |
*** global post <?php wp_get_attachment_image_src( $attachment_id, $size, $icon ); ?> | |
[0] => url | |
[1] => width | |
[2] => height | |
[3] => boolean: true if $url is a resized image, false if it is the original. | |
---- | |
<?php | |
global $post; | |
$args = array( 'posts_per_page' => 4, 'post_type'=> 'slider-items'); | |
$myposts = get_posts( $args ); | |
$count = 0; | |
foreach( $myposts as $post ) : setup_postdata($post); ?> | |
<?php endforeach; | |
wp_reset_postdata(); ?> | |
============================================= | |
EX.1--- | |
<?php | |
global $post; | |
$args = array( 'post_type'=> 'homepageinfo', 'posts_per_page' => 8); | |
$myposts = get_posts( $args ); | |
foreach( $myposts as $post ) : setup_postdata($post); ?> | |
<div class="tab-pane fade in row" id="tab-<?php the_ID(); ?>"> | |
<figure class="col-xs-5 col-sm-4"> | |
<?php the_post_thumbnail('homepageinformation-thumb', array('class' => 'img-responsive')); ?> | |
</figure> | |
<article class="tab-pane-body col-xs-7 col-sm-8"> | |
<?php the_content(); ?> | |
</article> | |
</div> | |
<?php endforeach; ?> | |
<?php wp_reset_postdata(); ?> | |
======================================================== | |
EX.2------------- | |
From Rasel Ahmed --------- | |
<?php | |
global $post; | |
$args = array( 'post_type'=> 'custom-post-type', 'posts_per_page' => 10 ); | |
$myposts = get_posts( $args ); | |
foreach( $myposts as $post ) : setup_postdata($post); ?> | |
<?php | |
$job_link = get_post_meta($post->ID, 'job_link', true); | |
$portfolio_image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large' ); | |
?> | |
<h2><?php the_title(); ?></h2> | |
<?php the_content(); ?> | |
<p><?php echo $job_link; ?></p> | |
<a href="<?php echo $portfolio_image[0]; ?> "></a> | |
<?php endforeach; ?> | |
<?php wp_reset_postdata(); ?> | |
===================================== ================================= | |
<?php if( is_home() || is_front_page() ) : ?> | |
<!-- Homepage Only Code --> | |
<?php else : ?> | |
<!-- Other Page Code --> | |
<?php endif; ?> | |
============================================================================= | |
Shordcode | |
EX.1 = | |
<?php | |
function btn_shortcode ($atts, $content = null){ | |
extract(shortcode_atts(array( | |
'type' => '', | |
'text' => '', | |
'link' => '', | |
'icon' =>'', | |
'value' =>'', | |
), | |
$atts) | |
); | |
return'<a class="btn btn-'.$type.'" href=" '.$link.' ">'.$text.'</a>'; | |
} | |
add_shortcode('btn','btn_shortcode'); | |
------------------------------------ | |
EX.2 | |
function accordion_list_shortcode($atts){ | |
extract( shortcode_atts( array( | |
'category' => '', | |
'count' => '5', | |
), $atts, 'wishlist' ) ); | |
$q = new WP_Query( | |
array('posts_per_page' => $count, 'post_type' => 'accordion-items', 'order', 'ASC', 'accordion_category' => $category) | |
); | |
$list = '<dl class="accordion toggles">'; | |
while($q->have_posts()) : $q->the_post(); | |
$idd = get_the_ID(); | |
$job_link = get_post_meta($post->ID, 'job_link', true); | |
$portfolio_image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large' ); | |
$list .= ' | |
<dt class="accordion-trigger"><i class="fa fa-question"></i> '.get_the_title().'</dt> | |
<dd class="accordion-content"> | |
<p>'.get_the_content().'</p> | |
</dd> | |
'; | |
endwhile; | |
$list.= '</dl>'; | |
wp_reset_query(); | |
return $list; | |
} | |
add_shortcode('accordion_list', 'accordion_list_shortcode'); | |
----------------------------------- | |
EX.3 | |
function testimonial_content_shortcode($atts){ | |
extract( shortcode_atts( array( | |
'category' => '', | |
'count' => '', | |
'type' => 'post', | |
), $atts ) ); | |
$q = new WP_Query( | |
array('posts_per_page' => $count, 'post_type' => 'testimonial-items', 'order', 'ASC' ) | |
); | |
$list = '<div class="col-md-6 wow fadeIn belal_all_testimonial" data-wow-duration="0.6s" data-wow-delay="0.3s">'; | |
while($q->have_posts()) : $q->the_post(); | |
$idd = get_the_ID(); | |
$client_name = get_post_meta($idd, 'client_name', true); | |
$company_name = get_post_meta($idd, 'company_name', true); | |
$list .= ' | |
<div id="testimonial-'.$idd.'" class="testimonail-detail"> | |
<p> | |
'.get_the_content().' | |
</p> | |
<div class="testimonial-info">'; | |
if( !empty($client_name) ) { | |
$list .= '<span class="company"> | |
Client Name: | |
</span><span class="name"> | |
'.$client_name.' | |
</span>'; | |
} | |
if( !empty($company_name) ) { | |
$list .= '<span class="company"> | |
Company Name: | |
</span> | |
<span class="name"> | |
'.$company_name.' | |
</span>'; | |
} | |
$list .= '</div> | |
</div>'; | |
endwhile; | |
$list.= '</div>'; | |
wp_reset_query(); | |
return $list; | |
} | |
add_shortcode('tcontent', 'testimonial_content_shortcode'); | |
------------------------- | |
*** //http://prowpexpert.com/query-shortcode-wordpress/ | |
function post_carousel_shortcode($atts){ | |
extract( shortcode_atts( array( | |
'type' => 'post', | |
), $atts, 'team' ) ); | |
$q = new WP_Query( | |
array('posts_per_page' => -1, 'post_type' => $type) | |
); | |
$list = '<div id="owl-portfolio" class="owl-carousel carousel-th">'; | |
while($q->have_posts()) : $q->the_post(); | |
$idd = get_the_ID(); | |
$team_sub = get_post_meta( $idd, 'team_subtitle', true ); | |
$portfolio_large = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'portfolio-large' ); | |
$portfolio_thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'portfolio-thumb' ); | |
$list .= ' | |
<div class="item"> | |
<figure class="icon-overlay icn-enlarge"><a href="'.$portfolio_large[0].'" class="fancybox-media" data-rel="portfolio"> <img src="'.$portfolio_thumb[0].'" alt="" /> </a></figure> | |
<div class="bordered no-top-border"> | |
<div class="info"> | |
<h3 class="post-title"><a href="'.get_permalink().'">'.get_the_title().'</a></h3> | |
<div class="meta"> <span class="date">'.get_the_time('M d, Y').'</span></div> | |
</div> | |
</div> | |
</div> | |
'; | |
endwhile; | |
$list.= '</div>'; | |
wp_reset_query(); | |
return $list; | |
} | |
add_shortcode('carousel', 'post_carousel_shortcode'); | |
--------------------------------------------------------------- | |
EX--4 BY ************ HK *********** | |
// Portfolio shortcode | |
function portfolio_shortcode($atts, $content = null){ | |
extract( shortcode_atts( array( | |
'type' => 'post', | |
), $atts ) ); | |
$q = new WP_Query( | |
array('posts_per_page' => 5, 'post_type' => 'portfolio') | |
); | |
$list = '<div class="row"> | |
<section id="projects"> | |
<ul id="thumbs" class="portfolio">'; | |
while($q->have_posts()) : $q->the_post(); | |
$idd = get_the_ID(); | |
$portfolio_large = wp_get_attachment_image_src( get_post_thumbnail_id( $idd ), 'portfolio-large' ); | |
$portfolio_thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $idd ), 'portfolio-image' ); | |
$list .= ' | |
<!-- Item Project and Filter Name --> | |
<li class="col-lg-3 design" data-id="id-0" data-type="web"> | |
<div class="item-thumbs"> | |
<!-- Fancybox - Gallery Enabled - Title - Full Image --> | |
<a class="hover-wrap fancybox" data-fancybox-group="gallery" title="'.get_the_title().'" href="'.$portfolio_large[0].'"> | |
<span class="overlay-img"></span> | |
<span class="overlay-img-thumb font-icon-plus"></span> | |
</a> | |
<img src="'.$portfolio_thumb[0].'" alt="'.get_the_title().'" /> | |
</div> | |
</li> | |
'; | |
endwhile; | |
$list.= '</ul></section></div>'; | |
wp_reset_query(); | |
return $list; | |
} | |
add_shortcode('portfolio', 'portfolio_shortcode'); | |
====================================================================== | |
Option tree | |
// Option Tree ei code functions.php te bosate hobe | |
/** | |
* Required: set 'ot_theme_mode' filter to true. | |
*/ | |
add_filter( 'ot_theme_mode', '__return_true' | |
//Disable Documentation | |
add_filter( 'ot_show_new_layout', '__return_false' ); | |
add_filter( 'ot_show_pages', '__return_false' ); | |
/** | |
* Required: include OptionTree. | |
*/ | |
require( trailingslashit( get_template_directory() ) . 'option-tree/ot-loader.php' ); | |
/** | |
* Meta Boxes | |
*/ | |
require( trailingslashit( get_template_directory() ) . 'include/meta-boxes.php' ); | |
/** | |
* Required: Adding theme option | |
*/ | |
include_once('inc/theme-options.php'); | |
------- | |
<?php | |
$header_logo = ot_get_option('headerlogo'); | |
$header_text = ot_get_option('headertext'); | |
?> | |
<?php if($header_logo): ?> | |
<a class="navbar-brand" href="<?php site_url(); ?>"><span><img src="<?php echo $header_logo; ?>" alt=""></span></a> | |
<?php else: ?> | |
<h2><a href="<?php site_url(); ?>"><?php echo $header_text; ?></a></h2> | |
<?php endif; ?> | |
------------------------------------ | |
Social Links in Header | |
$links = ot_get_option( 'your_option_id', false ); | |
if ( ! empty( $links ) { | |
echo '<pre>'; | |
print_r( $links ); | |
echo '</pre>'; | |
} | |
-------OR------ | |
<?php // Loop for Social Links | |
if (function_exists('ot_get_option')) { | |
/* get the option array */ | |
$links = ot_get_option('social_links', array()); | |
if (!empty($links)) { | |
foreach ($links as $link) { | |
echo '<li id="' . $link['title'] .'"><a href="' . $link['href'] . '"/> '. $link['title'] . ' </a></li>'; | |
} | |
} | |
} | |
?> | |
------------------------------------- | |
For List item or slider Option tree | |
<?php | |
$outmarkets = ot_get_option( 'my_outmarket', array() ); | |
if ( ! empty( $outmarkets ) ) { | |
foreach( $outmarkets as $outmarket ) { | |
echo ' | |
<li> | |
<h3><a href="' . $outmarket['outmarket_link'] . '"><img src="' . $outmarket['outmarket_icon'] . '" alt="">' . $outmarket['title'] . '</a></h3> | |
</li>'; | |
} | |
} | |
?> | |
=============================================================================================== | |
<?php query_posts(array( | |
'post_type' =>'slide', | |
'posts_per_page' =>4, | |
)); ?> | |
<?php while (have_posts()) : the_post (); ?> | |
<li> <?php the_title (); ?> </li> | |
<li> | |
<?php the_post_thumbnail('slide-image'); ?> | |
<div class="ilex-caption"> | |
<h3><?php the_title (); ?></h3> | |
<p><?php the_excerpt (); ?></p> | |
<a href="#" class="btn btn-theme">Learn More</a> | |
</div> | |
</li> | |
<?php endwhile ; ?> | |
<?php wp_reset_query(); ?> | |
============================================ | |
// Menu te page ana | |
<div class="collapse navbar-collapse"> | |
<ul class="nav navbar-nav"> | |
<?php global $post; $args=array( 'orderby'=> 'menu_order', | |
'post_type' => 'page', | |
'order' => 'ASC', | |
'posts_per_page' => -1); | |
$myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> | |
<li> | |
<a href="#<?php echo $post->post_name; ?>"> | |
<?php the_title(); ?> | |
</a> | |
</li> | |
<?php endforeach; wp_reset_postdata(); ?> | |
</ul> | |
</div> | |
============================================================================================= | |
/* | |
* Code for not reload commment frequently | |
*/ | |
function comment_scripts(){ | |
if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); | |
} | |
add_action( 'wp_enqueue_scripts', 'comment_scripts' ); | |
============================================================================================= | |
Comment er niche jate html code na showe kore se jonno etar pribotte <?php comment_form(); ?> | |
likhte hobe nicher code | |
<?php comment_form(array('comment_notes_after' => '')); ?> | |
============================================================================================= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment