Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <------ For Supporting To wordpeess Server------>
- /*
- Theme Name:
- Description: Wordpress theme
- Theme URI: http://www.azadbd.com
- Version:1.0
- Author URI: http://www.azadbd.com
- Author: Alberuni Azad.
- */
- <--------------------------------------------->
- /*------ For declearing HTML 4.01 version------*/
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- /**---------------------------------------------**/
- /*------ For declearing HTML 4.01 version------*/
- <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes('xhtml'); ?>>
- /**---------------------------------------------**/
- /*------ For declearing title in head section------*/
- <title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
- /**---------------------------------------------**/
- /*------ For declearing meta in head section------*/
- <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
- /**---------------------------------------------**/
- /*------ For declearing pingback------*/
- <link rel="profile" href="http://gmpg.org/xfn/11" />
- <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
- /**---------------------------------------------**/
- /*------ For bring header script (off course)------*/
- <?php wp_head(); ?>
- <?php wp_footer(); ?>
- /**---------------------------------------------**/
- /*------ For dynamic stylesheet------*/
- <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" media="screen" />
- /**---------------------------------------------**/
- /*------ For call any content from directory------*/
- <?php echo get_template_directory_uri(); ?>/
- /*Extra Tips With Replacing*/
- <img src="
- <img src="<?php echo get_template_directory_uri(); ?>/
- /**---------------------------------------------**/
- /*------ For dynamic site title------*/
- <title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
- For Tagline>>>>> <?php bloginfo('description'); ?>
- /**---------------------------------------------**/
- /*------ For bring Dynamic Menu------*/
- For Dynamic Menu
- functions.php
- function wpj_register_menu() {
- if (function_exists('register_nav_menu')) {
- register_nav_menu( 'main-menu', __( 'Main Menu') );
- }
- }
- add_action('init', 'wpj_register_menu');
- /*** For two menu Header & footer ***/
- function register_mainmenu() {
- if (function_exists('register_mainmenu')) {
- register_nav_menu( 'main-menu', __( 'Main Menu') );
- }
- register_nav_menu( 'footer-menu', __( 'Footer Menu') );
- }
- add_action('init', 'register_mainmenu');
- header.php
- <?php wp_nav_menu( array( 'theme_location' => 'main-menu') ); ?>
- <?php wp_nav_menu( array( 'theme_location' => 'main-menu','menu_id' => 'nav') ); ?>
- /**---------------------------------------------**/
- /*------ For adding menu by replacing UL------*/
- <?php wp_nav_menu( array( 'theme_location' => 'main_menu') ); ?>
- <?php wp_nav_menu( array( 'theme_location' => 'footer-menu') ); ?>
- /**---------------------------------------------**/
- /*------ For bring dynamic Posts to show in page------*/
- <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
- <h2><?php the_title(); ?></h2>
- <?php the_content(); ?>
- <?php endwhile; ?>
- <?php else : ?>
- <h3><?php _e('404 Error: Not Found', 'bilanti'); ?></h3>
- <?php endif; ?>
- /**---------------------------------------------**/
- /*------ For ragister a Widget------*/
- <?php
- function azad_widget() {
- register_sidebar( array(
- 'name' => __( ''),
- 'id' => '',
- 'before_widget' => '',
- 'after_widget' => '</div>',
- 'before_title' => '<h2>',
- 'after_title' => '</h2>',
- ) );
- }
- add_action('widgets_init', 'azad_widget');
- ?>
- /*-------- Conditoonal Widget-------------*/
- <?php if ( ! dynamic_sidebar( 'right_sidebar' ) ) : ?> <?php endif; ?>
- <?php dynamic_sidebar('blog_sidebar'); ?>
- /**---------------------------------------------**/
- /*------ For Post Query in index.php------*/
- <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
- <!-- Your Post Query here -->
- <?php endwhile; ?>
- <?php else : ?>
- <div class="post">
- <h3><?php _e('404 Error: Not Found', 'brightpage'); ?></h3>
- </div>
- <?php endif; ?>
- /**---------------------------------------------**/
- /**---------Query Post from a specific category--------------**/
- Query Post from a specific category
- <?php query_posts('post_type=post&post_status=publish&category-name=your_category_name&posts_per_page=10&paged='. get_query_var('paged')); ?>
- /**---------------------------------------------**/
- /*------For Post Information Query in index.php------*/
- <?php the_title(); ?> = to bring title
- <?php the_permalink(); ?> = to bring post link
- <?php the_time('M d, Y') ?> = to bring time, date or manth
- <?php the_excerpt(); ?> = to bring read more
- <?php the_content(); ?> = to bring full content
- <?php the_category(', '); ?> = to bring post catagory,
- <?php the_author_link(); ?>
- <?php comments_popup_link('No Comment', '1 Comment', '% Comments'); ?> = to bring post comment & his link
- /**---------------------------------------------**/
- /*------ For Pagination in index.php------*/
- Pagination in index.php
- =====================================
- <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts') ); ?></div><div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>') ); ?></div>
- /**---------------------------------------------**/
- /*------ For Single.php page------*/
- <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
- <h2><?php the_title(); ?></h2>
- <?php the_content(); ?>
- <?php comments_template( '', true ); ?>
- <?php endwhile; ?>
- <?php else : ?>
- <h3><?php _e('404 Error: Not Found'); ?></h3>
- <?php endif; ?>
- /**---------------------------------------------**/
- /*------ For Archive.php------*/
- for Archivezve Post List
- <h1 style="text-align: center;text-shadow: 3px 2px 7px #000000;font-size: 25px;line-height: 30px;">
- <?php if (have_posts()) : ?>
- <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
- <?php /* If this is a category archive */ if (is_category()) { ?>
- <?php _e('Archive for the'); ?> '<?php echo single_cat_title(); ?>' <?php _e('Category'); ?>
- <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
- <?php _e('Archive for the'); ?> <?php single_tag_title(); ?> Tag
- <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
- <?php _e('Archive for'); ?> <?php the_time('F jS, Y'); ?>
- <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
- <?php _e('Archive for'); ?> <?php the_time('F, Y'); ?>
- <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
- <?php _e('Archive for'); ?> <?php the_time('Y'); ?>
- <?php /* If this is a search */ } elseif (is_search()) { ?>
- <?php _e('Search Results'); ?>
- <?php /* If this is an author archive */ } elseif (is_author()) { ?>
- <?php _e('Author Archive'); ?>
- <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
- <?php _e('Blog Archives'); ?>
- <?php } ?>
- </h1>
- For archive post query
- <?php get_template_part( 'post-excerpt' ); // Post Excerpt (post-excerpt.php) ?>
- If no post in archive or 404
- <?php else : ?>
- <h3><?php _e('404 Error: Not Found'); ?></h3>
- <?php endif; ?>
- /**---------------------------------------------**/
- /*------ For 404.php------*/
- <h2>404 Error: Not Found</h2>
- <p>Sorry, but the page you are trying to reach is unavailable or does not exist.</p>
- /**---------------------------------------------**/
- /*------ For bring dynamic Posts to show in page------*/
- Adding Comment CSS
- Pastebin Link for CSS: http://pastebin.com/VaxfkmMe
- functions.php
- For enable comment
- function comment_scripts(){
- if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
- }
- add_action( 'wp_enqueue_scripts', 'comment_scripts' );
- For enable featured image
- add_theme_support( 'post-thumbnails', array( 'post' ) );
- for enable crop feature
- set_post_thumbnail_size( 200, 200, true );
- add_image_size( 'post-image', 150, 150, true );
- post-loop.php
- Using Featured Image
- <?php the_post_thumbnail('post-image', array('class' => 'post-thumb')); ?>
- <?php
- $full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'portfolio-big' );
- ?>
- <?php echo $full_image_url[0]; ?>
- the_post_thumbnail('project_smal_image', array('class' => 'post-thumb'));
- /**---------------------------------------------**/
- /*------ For comments.css------*/
- /* ===================== comments ===================== */
- .comments {margin: 10px 0;}
- .comments h3 {margin:50px 0 30px 0;font-size:24px;}
- ol.commentlist { list-style:none; margin:0 0 1em; padding:0; text-indent:0; }
- ol.commentlist li { }
- ol.commentlist li.alt { }
- ol.commentlist li.bypostauthor {}
- ol.commentlist li.byuser {}
- ol.commentlist li.comment-author-admin {}
- ol.commentlist li.comment { border-bottom: 1px solid #ddd; padding:1em; margin-bottom: 10px; }
- ol.commentlist li div.comment-author {}
- ol.commentlist li div.vcard { font-size:20px;}
- ol.commentlist li div.vcard cite.fn { font-style:normal; }
- ol.commentlist li div.vcard cite.fn a.url {}
- ol.commentlist li div.vcard img.avatar {float:left; margin:0 1em 1em 0; }
- ol.commentlist li div.vcard img.avatar-32 {}
- ol.commentlist li div.vcard img.photo {}
- ol.commentlist li div.vcard span.says {}
- ol.commentlist li div.commentmetadata {}
- ol.commentlist li div.comment-meta { font-size:9px; margin-bottom: 10px;}
- ol.commentlist li div.comment-meta a { color: #aaa; }
- ol.commentlist li p { margin: 0; }
- ol.commentlist li ul { list-style:square; margin:0 0 1em 2em; }
- ol.commentlist li div.reply { font-size:11px; }
- ol.commentlist li div.reply a { font-weight:bold; }
- ol.commentlist li ul.children { list-style:none; margin:1em 0 0; text-indent:0; }
- ol.commentlist li ul.children li {}
- ol.commentlist li ul.children li.alt {}
- ol.commentlist li ul.children li.bypostauthor {}
- ol.commentlist li ul.children li.byuser {}
- ol.commentlist li ul.children li.comment {}
- ol.commentlist li ul.children li.comment-author-admin {}
- ol.commentlist li ul.children li.depth-2 { margin:0 0 .25em .25em; }
- ol.commentlist li ul.children li.depth-3 { margin:0 0 .25em .25em; }
- ol.commentlist li ul.children li.depth-4 { margin:0 0 .25em .25em; }
- ol.commentlist li ul.children li.depth-5 {}
- ol.commentlist li ul.children li.odd {}
- ol.commentlist li.even { background:#fff; }
- ol.commentlist li.odd { background:#f6f6f6; }
- ol.commentlist li.parent { }
- ol.commentlist li.pingback { margin: 0 0 10px; padding: 1em; border: 1px dashed #ccc; }
- ol.commentlist li.thread-alt { }
- ol.commentlist li.thread-even { }
- ol.commentlist li.thread-odd {}
- /* ===================== comment form ===================== */
- #respond {position: relative;}
- #respond input[type="text"],#respond textarea {border:1px solid #ddd;padding:10px}
- #respond input[type="text"] {padding:7px;width:300px}
- #respond .comment-form-author,
- #respond .comment-form-email,
- #respond .comment-form-url,
- #respond .comment-form-comment { position: relative; }
- #respond .comment-form-author label,
- #respond .comment-form-email label,
- #respond .comment-form-url label,
- #respond .comment-form-comment label { background: #eee; color: #555; display: inline-block; left: 4px; min-width: 60px; padding: 4px 10px; position: relative; top: 40px; z-index: 1; }
- #respond input[type="text"]:focus,
- #respond textarea:focus { text-indent: 0; z-index: 1; }
- #respond textarea { resize: vertical; width: 95%;height: 220px; }
- #respond .comment-form-author .required,
- #respond .comment-form-email .required { color: #bd3500; font-size: 22px; font-weight: bold; left: 75%; position: absolute; top: 45px; z-index: 1; }
- #respond .comment-notes,
- #respond .logged-in-as { font-size: 13px; }
- #respond p { margin: 10px 0; }
- #respond .form-submit { float: right; margin: -20px 0 10px; }
- #respond input#submit { background: #454545; border: none; -moz-border-radius: 3px; border-radius: 3px; -webkit-box-shadow: 0px 1px 2px rgba(0,0,0,0.3); -moz-box-shadow: 0px 1px 2px rgba(0,0,0,0.3); box-shadow: 0px 1px 2px rgba(0,0,0,0.3); color: #eee; cursor: pointer; padding: 5px 42px 5px 22px; }
- #respond input#submit:active { background: #86222D; color: #fff; }
- #respond #cancel-comment-reply-link { color: #666; margin-left: 10px; text-decoration: none; }
- #respond .logged-in-as a:hover,
- #respond #cancel-comment-reply-link:hover { text-decoration: underline; }
- .commentlist #respond { margin: 1.625em 0 0; width: auto; }
- #reply-title { color: #373737; font-size: 20px; }
- #cancel-comment-reply-link { color: #888; display: block; position: absolute; right: 1.625em; text-decoration: none; text-transform: uppercase; top: 1.1em; }
- #cancel-comment-reply-link:focus,
- #cancel-comment-reply-link:active,
- #cancel-comment-reply-link:hover { color: #ff4b33; }
- #respond label {display: block; float: right; font-size: 16px; line-height: 2.2em; width: 280px;}
- #respond input[type=text] {}
- #respond p { font-size: 12px; }
- p.comment-form-comment { margin: 0; }
- .form-allowed-tags { display: none; }
- .trackback { margin: 0 0 10px; padding: 1em; border: 1px dashed #ccc; }
- /**---------------------------------------------**/
- /*------ For bring An amazing readmore function------*/
- An amazing readmore function
- functions.php
- function excerpt($num) {
- $limit = $num+1;
- $excerpt = explode(' ', get_the_excerpt(), $limit);
- array_pop($excerpt);
- $excerpt = implode(" ",$excerpt)." <a href='" .get_permalink($post->ID) ." ' class='".readmore."'>Read More</a>";
- echo $excerpt;
- }
- Usage: <?php echo excerpt('15'); ?>
- /**---------------------------------------------**/
- /**---------Using Custom Templates--------------**/
- Using Custom Templates
- <?php
- /*
- * Template Name: Custom Template Name
- */
- get_header(); ?>
- /**---------------------------------------------**/
- /**---------Register Custom Post Types--------------**/
- /* Register Custom Post Types********************************************/
- function.php
- /**---------Register Custom Post Types--------------**/
- function create_post_type() {
- register_post_type( 'testimonial',
- array(
- 'labels' => array(
- 'name' => __( 'Testimonial' ),
- 'singular_name' => __( 'Testimonial' ),
- 'add_new' => __( 'Add New' ),
- 'add_new_item' => __( 'Add New Testimonial' ),
- 'edit_item' => __( 'Edit Testimonial' ),
- 'new_item' => __( 'New Testimonial' ),
- 'view_item' => __( 'View Testimonial' ),
- 'not_found' => __( 'Sorry, we couldn\'t find the Testimonial you are looking for.' )
- ),
- 'public' => true,
- 'publicly_queryable' => false,
- 'exclude_from_search' => true,
- 'menu_position' => 14,
- 'has_archive' => false,
- 'hierarchical' => false,
- 'capability_type' => 'page',
- 'rewrite' => array( 'slug' => 'testimonial' ),
- 'supports' => array( 'title', 'editor', 'custom-fields' )
- )
- );
- }
- add_action( 'init', 'create_post_type' );
- /**---------------------------------------------**/
- /**---------Query Custom Post List--------------**/
- <?php query_posts('post_type=testimonial&post_status=publish&posts_per_page=10&paged='. get_query_var('paged')); ?>
- /**---------------------------------------------**/
- /**---------Query Custom Post Single--------------**/
- copy your single.php file & rename single-<custom-post>.php
- <custom-post> = Custom Post Type
- /**---------------------------------------------**/
- =====================================================================================================
- // Register Custom Taxonomy
- =====================================================================================================
- <?php
- function pages_taxonomy() {
- register_taxonomy(
- 'pages_cat', //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
- 'page', //post type name
- array(
- 'hierarchical' => true,
- 'label' => 'Page Category', //Display name
- 'query_var' => true,
- 'rewrite' => array(
- 'slug' => 'page-category', // This controls the base slug that will display before each term
- 'with_front' => false // Don't display the category base before
- )
- )
- );
- }
- add_action( 'init', 'pages_taxonomy');
- <?
- =====================================================================================================
- // Custom Taxonomy Query
- =====================================================================================================
- <?php
- global $post;
- $args = array( 'posts_per_page' => -1, 'post_type'=> 'staff', 'department_cat' => 'Commerical' );
- $myposts = get_posts( $args );
- foreach( $myposts as $post ) : setup_postdata($post); ?>
- // Your Post Content. Title, detail etc.
- <?php endforeach; ?>
- /**---------Display Custom Field Data--------------**/
- Display Custom Field Data
- <?php $ = get_post_meta($post->ID, '', true); ?>
- <?php $key="url"; echo get_post_meta($post->ID, $key, true); ?>
- Display custom field if exists
- <?php $image = get_post_meta($post->ID, 'url', true);
- if($image) : ?>
- <img src="<?php echo $image; ?>" alt="" />
- <?php endif; ?>
- Conditional Custom Field
- <?php
- $url = get_post_meta( $post->ID, 'url', true );
- if ( $url ) {
- echo $url;
- } else {
- the_permalink();
- }
- ?>
- /**---------------------------------------------**/
- /**---------For adding theme option in admin pannel----------------**/
- befor it active need create a folder named includes & create a file in includes folder named theme-options.php
- then open theme-options.php & paste below codes.
- <?php
- add_action( 'admin_init', 'custom_theme_options', 1 );
- function custom_theme_options() {
- $saved_settings = get_option( 'option_tree_settings', array() );
- $custom_settings = array(
- 'sections' => array(
- array(
- 'id' => 'general',
- 'title' => 'Site Settings'
- )
- ),
- 'settings' => array(
- array(
- 'id' => 'logo_text',
- 'label' => 'Logo Text',
- 'desc' => 'Use H1, H2, H3 tag',
- 'type' => 'textarea',
- 'section' => 'general'
- ),
- array(
- 'id' => 'footer_text',
- 'label' => 'Footer Text',
- 'type' => 'textarea',
- 'section' => 'general'
- )
- )
- );
- if ( $saved_settings !== $custom_settings ) {
- update_option( 'option_tree_settings', $custom_settings );
- }
- }
- ?>
- /**---------------------------------------------**//
- /**------------Activate Option Tree---------------------**/
- functions.php
- Activate Option Tree
- // add_filter( 'ot_show_pages', '__return_false' ); //For Turn on or Off Documentation
- add_filter( 'ot_show_new_layout', '__return_false' );
- add_filter( 'ot_theme_mode', '__return_true' );
- include_once( 'option-tree/ot-loader.php' );
- include_once( 'inc/theme-options.php' );
- include_once( 'inc/meta-boxes.php' );
- /**---------------------------------------------**//
- /**---------Get Data From Option Tree------------------**/
- Get Data From Option Tree
- ==========================
- Condtional Data
- <?php if ( function_exists( 'get_option_tree') ) : if( get_option_tree( 'logo_uploader') ) : ?>
- <?php get_option_tree( 'logo_uploader', '', 'true' ); ?>
- <?php else : ?>
- Your Default Data
- <?php endif; endif; ?>
- /**---------------------------------------------**/
- /**----------------Simple Data---------------**/
- Simple Data
- <?php get_option_tree( 'facebook', '', 'true' ); ?>
- /**---------------------------------------------**/
- /**** From Other Resorce ****/
- /**--------------For Post View count------------------**/
- functions.php
- function getPostViews($postID){
- $count_key = 'post_views_count';
- $count = get_post_meta($postID, $count_key, true);
- if($count==''){
- delete_post_meta($postID, $count_key);
- add_post_meta($postID, $count_key, '0');
- return "0 View";
- }
- return $count.' Views';
- }
- function setPostViews($postID) {
- $count_key = 'post_views_count';
- $count = get_post_meta($postID, $count_key, true);
- if($count==''){
- $count = 0;
- delete_post_meta($postID, $count_key);
- add_post_meta($postID, $count_key, '0');
- }else{
- $count++;
- update_post_meta($postID, $count_key, $count);
- }
- }
- single.php
- <?php setPostViews(get_the_ID()); ?>
- writwe below code where do u want to show post view counter
- <?php echo getPostViews(get_the_ID()); ?>
- /**---------------------------------------------**/
- /**----This code For dynamic copyright Text------**/
- footer.php
- <b>(c) <?php echo date('Y'); ?></b>
- | <a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a>
- | <?php bloginfo('description'); ?>
- /**---------------------------------------------**/
- /**--For wiew Posst or Comments publish Time---**/
- single.php
- <?php
- # For posts & pages #
- echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago';
- #Fo comments#
- echo human_time_diff(get_comment_time('U'), current_time('timestamp')) . ' ago';
- // Change to the date after a certain time
- $time_difference = current_time('timestamp') - get_the_time('U');
- if($time_difference < 86400) {
- //here goes the code from one of the sample above
- } else {
- the_time();
- };
- ?>
- /**---------------------------------------------**/
- /**-This code for pre define post when i write a post on wordpress---**/
- function.php
- add_filter( 'default_content', 'my_content' );
- function my_content( $content ) {
- $content = "your content here.";
- return $content;
- }
- /**---------------------------------------------**/
- /**-----------Slider Custom Post-------------**/
- <?php if(!is_paged()) { ?>
- <?php
- $args = array( 'post_type' => 'slider', 'posts_per_page' => 5 );
- $loop = new WP_Query( $args );
- ?>
- <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
- <?php the_post_thumbnail('slide-image', array('class' => 'postthumbnails')); ?>
- <?php endwhile; ?>
- <?php wp_reset_query(); ?>
- <?php } ?>
- /**---------------------------------------------**/
- /**-----------ওয়ার্ডপ্রেসে ইমেজ আর টেক্সট আলাদা করুন ->---------------**/
- Functions.php তে লিখুন
- // Stop images getting wrapped up in p tags when they get dumped out with
- the_content() for easier theme styling
- function wpfme_remove_img_ptags($content){
- return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
- }
- add_filter('the_content', 'wpfme_remove_img_ptags');
- /**---------------------------------------------**/
- Title: custom background.
- ============================================
- head.php
- ..............
- replace the <body> tag using bellow the code.
- <body <?php body_class(); ?>>
- =============================================
- functions.php
- .........................
- this code put within the <?php ?> tag
- $defaults_azad= array(
- 'default-color' => '#000',
- 'default-image' => '',
- 'wp-head-callback' => '_custom_background_cb',
- 'admin-head-callback' => '',
- 'admin-preview-callback' => ''
- );
- add_theme_support( 'custom-background', $defaults_azad );
- ==============================================
- Title: custom Header/Logo
- =============================================
- head.php
- .........................
- Put this code where you want to upload your logo.
- <a href="<?php bloginfo('home'); ?>"><img src="<?php header_image(); ?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="" /></a>
- =============================================
- functions.php
- ..........................
- this code put within the <?php ?> tag
- add_theme_support( 'custom-header' );
- $defaults = array(
- 'default-image' => '',
- 'random-default' => true,
- 'width' => 1000
- 'height' => 200,
- 'flex-height' => true,
- 'flex-width' => true,
- 'default-text-color' => '#000',
- 'header-text' => true,
- 'uploads' => true,
- 'wp-head-callback' => '',
- 'admin-head-callback' => '',
- 'admin-preview-callback' => '',
- );
- add_theme_support( 'custom-header', $defaults );
- আমার ব্লগে যে কেউ ফটো আপলোড করুকনা কেন সে অন্যের ফটো ও দেখতে পারে এইটা বন্ধ করব কিভাবে
- /**-------------Function for ---------------**/
- function strawberry_author_media( $wp_query ) {
- //are we looking at the Media Library or the Posts list?
- if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/upload.php' ) !== false
- || strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
- //user level 5 converts to Editor
- if ( !current_user_can( 'level_5' ) ) {
- //restrict the query to current user
- global $current_user;
- $wp_query->set( 'author', $current_user->id );
- }
- }
- }
- add_filter('parse_query', 'strawberry_author_media' );
- /**---------------------------------------------**/
- /**---------------------------------------------**/
- SMOF Options Framework Uses
- =========================================================================
- Single Data: <?php global $data; echo $data['your_option_id']; ?>
- Conditional Data:
- <?php global $data; ?>
- <?php if($data['your_option_id']): ?>
- <?php echo $data['your_option_id']; ?>
- <?php endif; ?>
- Conditional Data with Default Data
- <?php global $data; ?>
- <?php if($data['your_option_id']): ?>
- <?php echo $data['your_option_id']; ?>
- <?php else: ?>
- My Default Data
- <?php endif; ?>
- /**---------------------------------------------**/
- /**---------------------------------------------**/
- Conditional Options in functions
- =========================================================================
- $of_options[] = array( "name" => "Show Banner",
- "desc" => "You can use banner below logo and description",
- "id" => "show_banner",
- "on" => "Yes, I'd like to show banner",
- "off" => "Sorry, I don't want banner",
- "std" => 0,
- "folds" => 1,
- "type" => "switch"
- );
- $of_options[] = array( "name" => "Upload your banner",
- "desc" => "You can upload your banner from here",
- "id" => "custom_banner",
- "fold" => "show_banner", /* the switch hook */
- "type" => "upload"
- );
- Conditional Banner code in theme
- =========================================================================
- <?php global $data; ?>
- <?php if($data['show_banner']): ?>
- <img src="<?php echo $data['custom_banner']; ?>" alt="" />
- <?php else: ?>
- <?php endif; ?>
- /**---------------------------------------------**/
- /**-------------Related Post Using Category--------------------**/
- <div id="related_post">
- <?php
- $categories = get_the_category($post->ID);
- if ($categories) {
- $category_ids = array();
- foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
- $args=array(
- 'category__in' => $category_ids,
- 'post__not_in' => array($post->ID),
- 'showposts'=>5, // কতো সংখ্যক রিলেটেড পোস্ট দেখানো হবে।
- 'caller_get_posts'=>1
- );
- $my_query = new wp_query($args);
- if( $my_query->have_posts() ) {
- echo '<h2>Related Posts</h2><ul id="rel_item">';
- while ($my_query->have_posts()) : $my_query->the_post(); ?>
- <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
- <?php
- endwhile;
- echo '</ul>';
- }
- wp_reset_query();
- }
- ?>
- </div>
- /**------------CSS For Both-------------------**/
- #related_post {width:632px;text-align:left; position:relative;}
- #related_post h2{font-size:18px; font-weight:normal; overflow:hidden;}
- ul#rel_item {margin-top: -10px; padding:0px 0px;}
- ul#rel_item li{padding-bottom:7px; line-height:24px; font: 12px;}
- ul#rel_item li a:link, ul#rel_item li a:visited{color:#0199BC;}
- ul#rel_item li a:hover{color:#364D55;}
- /**---------------------------------------------**/
- /**---------------------------------------------**/
- <div id="related_post">
- <?php
- $categories = get_the_category($post->ID);
- if ($categories) {
- $category_ids = array();
- foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
- $args=array(
- 'category__in' => $category_ids,
- 'post__not_in' => array($post->ID),
- 'showposts'=>5, // কতো সংখ্যক রিলেটেড পোস্ট দেখানো হবে।
- 'caller_get_posts'=>1
- );
- /**---------------------------------------------**/
- /**------------Smooth Scrolling--------------**/
- $(document).ready(function() {
- function filterPath(string) {
- return string
- .replace(/^\//,'')
- .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
- .replace(/\/$/,'');
- }
- var locationPath = filterPath(location.pathname);
- var scrollElem = scrollableElement('html', 'body');
- $('a[href*=#]').each(function() {
- var thisPath = filterPath(this.pathname) || locationPath;
- if ( locationPath == thisPath
- && (location.hostname == this.hostname || !this.hostname)
- && this.hash.replace(/#/,'') ) {
- var $target = $(this.hash), target = this.hash;
- if (target) {
- var targetOffset = $target.offset().top;
- $(this).click(function(event) {
- event.preventDefault();
- $(scrollElem).animate({scrollTop: targetOffset}, 400, function() {
- location.hash = target;
- });
- });
- }
- }
- });
- // use the first element that is "scrollable"
- function scrollableElement(els) {
- for (var i = 0, argLength = arguments.length; i <argLength; i++) {
- var el = arguments[i],
- $scrollElement = $(el);
- if ($scrollElement.scrollTop()> 0) {
- return el;
- } else {
- $scrollElement.scrollTop(1);
- var isScrollable = $scrollElement.scrollTop()> 0;
- $scrollElement.scrollTop(0);
- if (isScrollable) {
- return el;
- }
- }
- }
- return [];
- }
- });
- /*--------Stiker----------*/
- $(document).ready(function() {
- var s = $("#sticker");
- var pos = s.position();
- $(window).scroll(function() {
- var windowpos = $(window).scrollTop();
- if (windowpos >= pos.top) {
- s.addClass("stick");
- } else {
- s.removeClass("stick");
- }
- });
- });
- div#sticker {
- padding:20px;
- margin:20px 0;
- background:#AAA;
- width:190px;
- }
- .stick {
- position:fixed;
- top:0px;
- }
- /**------------ For Search-------------------**/
- <form id="searchform" class="search fix" action="http://yourdomail.com/" method="get" role="search">
- <div>
- <label class="screen-reader-text" for="s"></label>
- <input class="search-field" id="s" type="text" name="s" value=""></div>
- </form>
- /* Search Widget Style */
- .screen-reader-text{
- float:left;
- font-size:17px;
- padding-bottom:15px;
- text-align:center;
- width:100%;
- }
- #s{
- background:none repeat scroll 0 0 #eeeeee;
- /*border-radius*/
- -webkit-border-radius:3px 3px 3px 3px;
- -moz-border-radius:3px 3px 3px 3px;
- border-radius:3px 3px 3px 3px;
- color:#000;
- /*transition*/
- -webkit-transition:background 300ms ease-in-out 0s;
- -moz-transition:background 300ms ease-in-out 0s;
- -o-transition:background 300ms ease-in-out 0s;
- transition:background 300ms ease-in-out 0s;
- width:40%;
- margin-right:5%;
- }
- input[type="submit"]{
- background:none repeat scroll 0 0 #444444;
- border:medium none;
- color:#FFFFFF;
- cursor:pointer;
- padding:5px 15px;
- width:40%;
- }
- add_theme_support( 'woocommerce' );
- //NUMBER OF PRODICTS TO DISPLAY ON SHOP PAGE
- add_filter('loop_shop_per_page', create_function('$cols', 'return 100;'));
- =================404=================
- <div style="display: block;margin: 0 auto;padding: 30px 0;">
- <h1 class="font-size: 50px;text-align: center;font-weight: normal;color:#ddd">
- <span>404</span>not found
- </h1>
- </div>
- /*=============FOR---Plugin============*/
- function boxed_css() {
- echo "
- <style type='text/css'>
- #boxed_style {border:5px solid red;padding:25px;}
- </style>
- ";
- }
- add_action ('wp_head', 'boxed_css');
- /* This Code for load jQuery from Wordpress */
- function latest_jquery_for_slider() {
- wp_enqueue_script('jquery');
- }
- add_action('init', 'latest_jquery_for_slider');
- /* This Code for load jQuery File depend on main jquery */
- function lazy_news_plugin_main_js() {
- wp_enqueue_script( 'lazy-news-js', plugins_url( '/js/jquery.ticker.min.js', __FILE__ ), array('jquery'), 1.0, false);
- }
- add_action('init','lazy_news_plugin_main_js');
- /* Loads Slider Javascript */
- function plugin_javasctipt_main_file() {
- wp_register_script( 'onekb_slider_script', plugins_url('rrf-one-kb-slider/js/responsiveslides.min.js'), false, '1.0', true);
- wp_enqueue_script( 'onekb_slider_script' );
- }
- add_action( 'wp_footer', 'plugin_javasctipt_main_file' );
- /* Active Slider */
- function plugin_javasctipt_active_file() {
- wp_register_script( 'onekb_slider_active', plugins_url('rrf-one-kb-slider/js/active.js'), false, '1.0', true);
- wp_enqueue_script( 'onekb_slider_active' );
- }
- add_action( 'wp_footer', 'plugin_javasctipt_active_file' );
- /* Load Slider Custom CSS */
- function onekb_slider_plugin_styles() {
- wp_register_style( 'onekb_slider_plugin_style', plugins_url('css/custom.css', __FILE__) );
- wp_enqueue_style(onekb_slider_plugin_style);
- }
- add_action( 'wp_enqueue_scripts', 'onekb_slider_plugin_styles' );
- /* Load Quotes Custom CSS */
- function quotes_stylesheet() {
- // Enqueue the CSS
- wp_enqueue_style('quotes_style',plugins_url( 'css/component.css', __FILE__),false,1.0,'all');
- }
- add_action( 'wp_enqueue_scripts', 'quotes_stylesheet');
- /* Generates Slider Shortcode */
- function slider($atts, $content = null) {
- return ('<ul class="rslides">'.do_shortcode($content).'</ul>');
- }
- add_shortcode ("slider", "slider");
- function slides($atts, $content = null) {
- return ('<li><img src="'.$content.'" alt=""/></li>');
- }
- add_shortcode ("slides", "slides");
- /* Add Slider Shortcode Button on Post Visual Editor */
- function onekbslider_button() {
- add_filter ("mce_external_plugins", "slider_button_js");
- add_filter ("mce_buttons", "slider_button");
- }
- function slider_button_js($plugin_array) {
- $plugin_array['wptuts'] = plugins_url('js/custom-button.js', __FILE__);
- return $plugin_array;
- }
- function slider_button($buttons) {
- array_push ($buttons, 'slider');
- return $buttons;
- }
- add_action ('init', 'onekbslider_button');
- ==================WooCommerce====================
- /*=============== BD Currency =================*/
- add_filter( 'woocommerce_currencies', 'add_my_currency' );
- function add_my_currency( $currencies ) {
- $currencies['BDT'] = __( 'Currency name', 'woocommerce' );
- return $currencies;
- }
- add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2);
- function add_my_currency_symbol( $currency_symbol, $currency ) {
- switch( $currency ) {
- case 'BDT': $currency_symbol = 'Tk'; break;
- }
- return $currency_symbol;
- }
- ==================Related Post by Same Author ====================
- function get_related_author_posts() {
- global $authordata, $post;
- $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5 ) );
- $output = '<ul>';
- foreach ( $authors_posts as $authors_post ) {
- $output .= '<li><a href="' . get_permalink( $authors_post->ID ) . '">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a></li>';
- }
- $output .= '</ul>';
- return $output;
- }
- Place this code in single.php to show the related post:
- <div style="background:#ddd;color:#fff;">
- <?php echo get_related_author_posts(); ?>
- </div>
- ==================Post View Count ====================
- /*Use on functions.php function to display number of posts.*/
- function getPostViews($postID){
- $count_key = 'post_views_count';
- $count = get_post_meta($postID, $count_key, true);
- if($count==''){
- delete_post_meta($postID, $count_key);
- add_post_meta($postID, $count_key, '0');
- return "0 View";
- }
- return $count.' Views';
- }
- // function to count views.
- function setPostViews($postID) {
- $count_key = 'post_views_count';
- $count = get_post_meta($postID, $count_key, true);
- if($count==''){
- $count = 0;
- delete_post_meta($postID, $count_key);
- add_post_meta($postID, $count_key, '0');
- }else{
- $count++;
- update_post_meta($postID, $count_key, $count);
- }
- }
- // Add it to a column in WP-Admin
- add_filter('manage_posts_columns', 'posts_column_views');
- add_action('manage_posts_custom_column', 'posts_custom_column_views',5,2);
- function posts_column_views($defaults){
- $defaults['post_views'] = __('Views');
- return $defaults;
- }
- function posts_custom_column_views($column_name, $id){
- if($column_name === 'post_views'){
- echo getPostViews(get_the_ID());
- }
- } /*Lastly, to display the number of views a post has, just add this where you want it to be displayed:*/
- <?php echo getPostViews(get_the_ID()); ?>
- ============================ Multilanguage Qtranslate ===============================
- /*For manually*/
- [:en]English Text[:fr]French Text[:de]German Text
- /** Memory Limit */
- define('WP_MEMORY_LIMIT', '64M');
- /* That's all, stop editing! Happy blogging. */
- set_time_limit(300);
- ====================== Post Meta ==============================
- $promotions_icon = get_post_meta($post->ID, 'promotions_icon', true);
- ====================== Shortcode Custom Field ==============================
- $product_price_dollar = get_post_meta($idd, 'product_price_dollar', true);
- # Changing Default Title of 'qtrotator' Csutom post
- function change_default_title( $title ) {
- $screen = get_current_screen();
- switch ($screen->post_type) {
- case 'qtrotator':
- $title = 'qtrotator';
- break;
- case 'page':
- $title = 'page';
- break;
- default:
- $title = 'Enter Default Post Title Heree';
- break;
- }
- return $title;
- }
- add_filter( 'enter_title_here', 'change_default_title', 10, 2 );
- Load modernizr in plugin:
- ===============================
- function wpb_modernizr() {
- wp_deregister_script('modernizr'); // deregister
- wp_enqueue_script('wp_enqueue_scripts', plugins_url('/js/modernizr.custom.js', __FILE__), false, '2.7.0', false);
- }
- add_action('wp_enqueue_scripts', 'wpb_modernizr');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement