View difference between Paste ID: Gh64tBQ1 and emNhXyQy
SHOW: | | - or go back to the newest paste.
1
	
2
3
    <------ For Supporting To wordpeess Server------>
4
    /*
5
    Theme Name:
6
    Description: Wordpress theme
7
    Theme URI: http://www.azadbd.com
8
    Version:1.0
9
    Author URI: http://www.azadbd.com
10
    Author: Alberuni Azad.
11
    */
12
    <--------------------------------------------->
13
     
14
     
15
    /*------ For declearing HTML 4.01 version------*/
16
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
17
    /**---------------------------------------------**/
18
     
19
     
20
    /*------ For declearing HTML 4.01 version------*/
21
    <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes('xhtml'); ?>>
22
    /**---------------------------------------------**/
23
     
24
    /*------ For declearing title in head section------*/
25
    <title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
26
    /**---------------------------------------------**/
27
     
28
    /*------ For declearing meta in head section------*/
29
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />    
30
    /**---------------------------------------------**/
31
     
32
     
33
    /*------ For declearing pingback------*/
34
    <link rel="profile" href="http://gmpg.org/xfn/11" />
35
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
36
    /**---------------------------------------------**/
37
     
38
     
39
    /*------ For bring header script (off course)------*/
40
    <?php wp_head(); ?>
41
    <?php wp_footer(); ?>
42
    /**---------------------------------------------**/
43
     
44
     
45
    /*------ For dynamic stylesheet------*/
46
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" media="screen" />
47
    /**---------------------------------------------**/
48
     
49
     
50
    /*------ For call any content from directory------*/
51
    <?php echo get_template_directory_uri(); ?>/
52
     
53
    /*Extra Tips With Replacing*/
54
    <img src="
55
    <img src="<?php echo get_template_directory_uri(); ?>/
56
    /**---------------------------------------------**/
57
     
58
     
59
    /*------ For dynamic site title------*/
60
    <title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
61
    For Tagline>>>>>  <?php bloginfo('description'); ?>
62
    /**---------------------------------------------**/
63
     
64
    /*------ For bring  Dynamic Menu------*/
65
    For Dynamic Menu
66
     
67
    functions.php
68
     
69
    function wpj_register_menu() {
70
        if (function_exists('register_nav_menu')) {
71
           register_nav_menu( 'main-menu', __( 'Main Menu') );
72
        }
73
     
74
    }
75
    add_action('init', 'wpj_register_menu');
76
     
77
    /*** For two menu Header & footer ***/
78
     
79
    function register_mainmenu() {
80
        if (function_exists('register_mainmenu')) {
81
           register_nav_menu( 'main-menu', __( 'Main Menu') );
82
        }
83
            register_nav_menu( 'footer-menu', __( 'Footer Menu') );
84
     
85
    }
86
    add_action('init', 'register_mainmenu');
87
     
88
    header.php
89
    <?php wp_nav_menu( array( 'theme_location' => 'main-menu') ); ?>
90
     
91
    <?php wp_nav_menu( array( 'theme_location' => 'main-menu','menu_id' => 'nav') ); ?>
92
    /**---------------------------------------------**/
93
     
94
    /*------ For adding menu by replacing UL------*/
95
    <?php wp_nav_menu( array( 'theme_location' => 'main_menu') ); ?>
96
    <?php wp_nav_menu( array( 'theme_location' => 'footer-menu') ); ?>
97
    /**---------------------------------------------**/
98
     
99
     
100
    /*------ For bring dynamic Posts to show in page------*/
101
                                                    <?php if(have_posts()) : ?><?php while(have_posts())  : the_post(); ?>
102
                                                            <h2><?php the_title(); ?></h2>
103
                                                            <?php the_content(); ?>
104
                                                    <?php endwhile; ?>
105
                                                   
106
                                                    <?php else : ?>
107
                                                            <h3><?php _e('404 Error&#58; Not Found', 'bilanti'); ?></h3>
108
                                                    <?php endif; ?>
109
    /**---------------------------------------------**/
110
     
111
     
112
    /*------ For ragister a Widget------*/
113
    <?php
114
    function azad_widget() {
115
            register_sidebar( array(
116
                    'name' => __( ''),
117
                    'id' => '',
118
                    'before_widget' => '',
119
                    'after_widget' => '</div>',
120
                'before_title' => '<h2>',
121
                'after_title' => '</h2>',
122
            ) );
123
    }
124
    add_action('widgets_init', 'azad_widget');
125
     ?>
126
     
127
     /*-------- Conditoonal Widget-------------*/
128
    <?php if ( ! dynamic_sidebar( 'right_sidebar' ) ) : ?> <?php endif; ?>
129
     
130
     <?php dynamic_sidebar('blog_sidebar'); ?>
131
     
132
     
133
    /**---------------------------------------------**/
134
     
135
     
136
    /*------ For Post Query in index.php------*/
137
    <?php if(have_posts()) : ?><?php while(have_posts())  : the_post(); ?>
138
         
139
    <!-- Your Post Query here -->
140
     
141
    <?php endwhile; ?>
142
    <?php else : ?>
143
            <div class="post">
144
                    <h3><?php _e('404 Error&#58; Not Found', 'brightpage'); ?></h3>
145
            </div>
146
    <?php endif; ?>        
147
    /**---------------------------------------------**/
148
     
149
     
150
    /**---------Query Post from a specific category--------------**/
151
    Query Post from a specific category
152
    <?php query_posts('post_type=post&post_status=publish&category-name=your_category_name&posts_per_page=10&paged='. get_query_var('paged')); ?>
153
    /**---------------------------------------------**/
154
     
155
     
156
     
157
     
158
    /*------For Post Information Query in index.php------*/
159
    <?php the_title(); ?> = to bring title
160
     
161
    <?php the_permalink(); ?> = to bring post link
162
     
163
    <?php the_time('M d, Y') ?> = to bring time, date or manth
164
     
165
    <?php the_excerpt(); ?> = to bring read more
166
     
167
    <?php the_content(); ?> = to bring full content
168
     
169
    <?php the_category(', '); ?> = to bring post catagory,
170
    <?php the_author_link(); ?>
171
     
172
    <?php comments_popup_link('No Comment', '1 Comment', '% Comments'); ?> = to bring post comment & his link
173
    /**---------------------------------------------**/
174
     
175
     
176
    /*------ For Pagination in index.php------*/
177
    Pagination in index.php
178
    =====================================
179
    <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts') ); ?></div><div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>') ); ?></div>
180
    /**---------------------------------------------**/
181
     
182
     
183
    /*------ For Single.php page------*/
184
    <?php if(have_posts()) : ?><?php while(have_posts())  : the_post(); ?>
185
        <h2><?php the_title(); ?></h2>
186
        <?php the_content(); ?>
187
       <?php comments_template( '', true ); ?>  
188
    <?php endwhile; ?>
189
     
190
    <?php else : ?>
191
        <h3><?php _e('404 Error&#58; Not Found'); ?></h3>
192
    <?php endif; ?>
193
    /**---------------------------------------------**/
194
     
195
     
196
    /*------ For Archive.php------*/
197
    for Archivezve Post List
198
     
199
     
200
     
201
    <h1 style="text-align: center;text-shadow: 3px 2px 7px #000000;font-size: 25px;line-height: 30px;">
202
        <?php if (have_posts()) : ?>
203
            <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
204
                <?php /* If this is a category archive */ if (is_category()) { ?>
205
                    <?php _e('Archive for the'); ?> '<?php echo single_cat_title(); ?>' <?php _e('Category'); ?>                                    
206
                <?php /* If this is a tag archive */  } elseif( is_tag() ) { ?>
207
                    <?php _e('Archive for the'); ?> <?php single_tag_title(); ?> Tag
208
                <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
209
                    <?php _e('Archive for'); ?> <?php the_time('F jS, Y'); ?>                                        
210
                <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
211
                    <?php _e('Archive for'); ?> <?php the_time('F, Y'); ?>                                    
212
                <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
213
                    <?php _e('Archive for'); ?> <?php the_time('Y'); ?>                                        
214
                <?php /* If this is a search */ } elseif (is_search()) { ?>
215
                    <?php _e('Search Results'); ?>                            
216
                <?php /* If this is an author archive */ } elseif (is_author()) { ?>
217
                    <?php _e('Author Archive'); ?>                                        
218
                <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
219
                    <?php _e('Blog Archives'); ?>                                        
220
        <?php } ?>
221
    </h1>
222
     
223
    For archive post query
224
     
225
    <?php get_template_part( 'post-excerpt' ); // Post Excerpt (post-excerpt.php) ?>
226
     
227
    If no post in archive or 404
228
     
229
    <?php else : ?>
230
        <h3><?php _e('404 Error&#58; Not Found'); ?></h3>
231
    <?php endif; ?>
232
    /**---------------------------------------------**/
233
     
234
     
235
    /*------ For 404.php------*/
236
    <h2>404 Error&#58; Not Found</h2>
237
    <p>Sorry, but the page you are trying to reach is unavailable or does not exist.</p>
238
    /**---------------------------------------------**/
239
     
240
     
241
    /*------ For bring dynamic Posts to show in page------*/
242
    Adding Comment CSS
243
    Pastebin Link for CSS: http://pastebin.com/VaxfkmMe
244
     
245
    functions.php
246
    For enable comment
247
     
248
    function comment_scripts(){
249
       if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
250
    }
251
    add_action( 'wp_enqueue_scripts', 'comment_scripts' );
252
     
253
    For enable featured image
254
    add_theme_support( 'post-thumbnails', array( 'post' ) );
255
     
256
    for enable crop feature
257
    set_post_thumbnail_size( 200, 200, true );
258
    add_image_size( 'post-image', 150, 150, true );
259
     
260
    post-loop.php
261
     
262
    Using Featured Image
263
    <?php the_post_thumbnail('post-image', array('class' => 'post-thumb')); ?>
264
     
265
    <?php
266
            $full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'portfolio-big' );
267
    ?>
268
     
269
    <?php echo $full_image_url[0]; ?>
270
     
271
    the_post_thumbnail('project_smal_image', array('class' => 'post-thumb'));
272
     
273
    /**---------------------------------------------**/
274
     
275
     
276
    /*------ For comments.css------*/
277
    /* ===================== comments ===================== */
278
     
279
    .comments {margin: 10px 0;}
280
    .comments h3 {margin:50px 0 30px 0;font-size:24px;}
281
    ol.commentlist { list-style:none; margin:0 0 1em; padding:0; text-indent:0; }
282
    ol.commentlist li { }
283
    ol.commentlist li.alt { }
284
    ol.commentlist li.bypostauthor {}
285
    ol.commentlist li.byuser {}
286
    ol.commentlist li.comment-author-admin {}
287
    ol.commentlist li.comment { border-bottom: 1px solid #ddd; padding:1em; margin-bottom: 10px; }
288
    ol.commentlist li div.comment-author {}
289
    ol.commentlist li div.vcard { font-size:20px;}
290
    ol.commentlist li div.vcard cite.fn { font-style:normal; }
291
    ol.commentlist li div.vcard cite.fn a.url {}
292
    ol.commentlist li div.vcard img.avatar {float:left; margin:0 1em 1em 0; }
293
    ol.commentlist li div.vcard img.avatar-32 {}
294
    ol.commentlist li div.vcard img.photo {}
295
    ol.commentlist li div.vcard span.says {}
296
    ol.commentlist li div.commentmetadata {}
297
    ol.commentlist li div.comment-meta { font-size:9px; margin-bottom: 10px;}
298
    ol.commentlist li div.comment-meta a { color: #aaa; }
299
    ol.commentlist li p { margin: 0; }
300
    ol.commentlist li ul { list-style:square; margin:0 0 1em 2em; }
301
    ol.commentlist li div.reply { font-size:11px; }
302
    ol.commentlist li div.reply a { font-weight:bold; }
303
    ol.commentlist li ul.children { list-style:none; margin:1em 0 0; text-indent:0; }
304
    ol.commentlist li ul.children li {}
305
    ol.commentlist li ul.children li.alt {}
306
    ol.commentlist li ul.children li.bypostauthor {}
307
    ol.commentlist li ul.children li.byuser {}
308
    ol.commentlist li ul.children li.comment {}
309
    ol.commentlist li ul.children li.comment-author-admin {}
310
    ol.commentlist li ul.children li.depth-2 { margin:0 0 .25em .25em; }
311
    ol.commentlist li ul.children li.depth-3 { margin:0 0 .25em .25em; }
312
    ol.commentlist li ul.children li.depth-4 { margin:0 0 .25em .25em; }
313
    ol.commentlist li ul.children li.depth-5 {}
314
    ol.commentlist li ul.children li.odd {}
315
    ol.commentlist li.even { background:#fff; }
316
    ol.commentlist li.odd { background:#f6f6f6; }
317
    ol.commentlist li.parent { }
318
    ol.commentlist li.pingback { margin: 0 0 10px; padding: 1em; border: 1px dashed #ccc; }
319
    ol.commentlist li.thread-alt { }
320
    ol.commentlist li.thread-even { }
321
    ol.commentlist li.thread-odd {}
322
     
323
    /* ===================== comment form ===================== */
324
     
325
    #respond {position: relative;}
326
    #respond input[type="text"],#respond textarea {border:1px solid #ddd;padding:10px}
327
    #respond input[type="text"] {padding:7px;width:300px}
328
    #respond .comment-form-author,
329
    #respond .comment-form-email,
330
    #respond .comment-form-url,
331
    #respond .comment-form-comment { position: relative; }
332
    #respond .comment-form-author label,
333
    #respond .comment-form-email label,
334
    #respond .comment-form-url label,
335
    #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; }
336
    #respond input[type="text"]:focus,
337
    #respond textarea:focus { text-indent: 0; z-index: 1; }
338
    #respond textarea { resize: vertical; width: 95%;height: 220px; }
339
    #respond .comment-form-author .required,
340
    #respond .comment-form-email .required { color: #bd3500; font-size: 22px; font-weight: bold; left: 75%; position: absolute; top: 45px; z-index: 1; }
341
    #respond .comment-notes,
342
    #respond .logged-in-as { font-size: 13px; }
343
    #respond p { margin: 10px 0; }
344
    #respond .form-submit { float: right; margin: -20px 0 10px; }
345
    #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; }
346
    #respond input#submit:active { background: #86222D; color: #fff; }
347
    #respond #cancel-comment-reply-link { color: #666; margin-left: 10px; text-decoration: none; }
348
    #respond .logged-in-as a:hover,
349
    #respond #cancel-comment-reply-link:hover { text-decoration: underline; }
350
    .commentlist #respond { margin: 1.625em 0 0; width: auto; }
351
    #reply-title { color: #373737; font-size: 20px; }
352
    #cancel-comment-reply-link { color: #888; display: block; position: absolute; right: 1.625em; text-decoration: none; text-transform: uppercase; top: 1.1em; }
353
    #cancel-comment-reply-link:focus,
354
    #cancel-comment-reply-link:active,
355
    #cancel-comment-reply-link:hover { color: #ff4b33; }
356
    #respond label {display: block; float: right; font-size: 16px; line-height: 2.2em; width: 280px;}
357
    #respond input[type=text] {}
358
    #respond p { font-size: 12px; }
359
    p.comment-form-comment { margin: 0; }
360
    .form-allowed-tags { display: none; }
361
    .trackback { margin: 0 0 10px; padding: 1em; border: 1px dashed #ccc; }
362
    /**---------------------------------------------**/
363
     
364
     
365
     
366
     
367
     
368
    /*------ For bring An amazing readmore function------*/
369
    An amazing readmore function
370
     
371
    functions.php
372
     
373
    function excerpt($num) {
374
    $limit = $num+1;
375
    $excerpt = explode(' ', get_the_excerpt(), $limit);
376
    array_pop($excerpt);
377
    $excerpt = implode(" ",$excerpt)." <a href='" .get_permalink($post->ID) ." ' class='".readmore."'>Read More</a>";
378
    echo $excerpt;
379
    }
380
     
381
    Usage: <?php echo excerpt('15'); ?>
382
    /**---------------------------------------------**/
383
     
384
    /**---------Using Custom Templates--------------**/
385
    Using Custom Templates
386
     
387
    <?php
388
    /*
389
     * Template Name: Custom Template Name
390
     */
391
    get_header(); ?>
392
    /**---------------------------------------------**/
393
     
394
     
395
     
396
     
397
     
398
    /**---------Register Custom Post Types--------------**/
399
    /* Register Custom Post Types********************************************/
400
    function.php
401
     
402
    /**---------Register Custom Post Types--------------**/
403
            function create_post_type() {
404
                    register_post_type( 'testimonial',
405
                            array(
406
                                    'labels' => array(
407
                                            'name' => __( 'Testimonial' ),
408
                                            'singular_name' => __( 'Testimonial' ),
409
                                            'add_new' => __( 'Add New' ),
410
                                            'add_new_item' => __( 'Add New Testimonial' ),
411
                                            'edit_item' => __( 'Edit Testimonial' ),
412
                                            'new_item' => __( 'New Testimonial' ),
413
                                            'view_item' => __( 'View Testimonial' ),
414
                                            'not_found' => __( 'Sorry, we couldn\'t find the Testimonial you are looking for.' )
415
                                    ),
416
                            'public' => true,
417
                            'publicly_queryable' => false,
418
                            'exclude_from_search' => true,
419
                            'menu_position' => 14,
420
                            'has_archive' => false,
421
                            'hierarchical' => false,
422
                            'capability_type' => 'page',
423
                            'rewrite' => array( 'slug' => 'testimonial' ),
424
                            'supports' => array( 'title', 'editor', 'custom-fields' )
425
                            )
426
                    );
427
            }
428
            add_action( 'init', 'create_post_type' );
429
    /**---------------------------------------------**/
430
     
431
     
432
    /**---------Query Custom Post List--------------**/
433
    <?php query_posts('post_type=testimonial&post_status=publish&posts_per_page=10&paged='. get_query_var('paged')); ?>
434
    /**---------------------------------------------**/
435
     
436
     
437
    /**---------Query Custom Post Single--------------**/
438
    copy your single.php file & rename single-<custom-post>.php
439
    <custom-post> = Custom Post Type
440
    /**---------------------------------------------**/
441
     
442
     
443
     
444
     
445
    =====================================================================================================
446
    // Register Custom Taxonomy
447
    =====================================================================================================
448
    <?php
449
    function pages_taxonomy() {
450
            register_taxonomy(
451
                    'pages_cat',  //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
452
                    'page',                  //post type name
453
                    array(
454
                            'hierarchical'          => true,
455
                            'label'                         => 'Page Category',  //Display name
456
                            'query_var'             => true,
457
                            'rewrite'                       => array(
458
                                    'slug'                  => 'page-category', // This controls the base slug that will display before each term
459
                                    'with_front'    => false // Don't display the category base before
460
                                    )
461
                            )
462
            );
463
    }
464
    add_action( 'init', 'pages_taxonomy');         
465
    <?     
466
     
467
    =====================================================================================================
468
    // Custom Taxonomy Query
469
    =====================================================================================================
470
     
471
    <?php
472
    global $post;
473
    $args = array( 'posts_per_page' => -1, 'post_type'=> 'staff', 'department_cat' => 'Commerical' );
474
    $myposts = get_posts( $args );
475
    foreach( $myposts as $post ) : setup_postdata($post); ?>
476
                                   
477
            // Your Post Content. Title, detail etc.
478
                                   
479
    <?php endforeach; ?>
480
     
481
     
482
     
483
     
484
     
485
     
486
     
487
     
488
    /**---------Display Custom Field Data--------------**/
489
    Display Custom Field Data
490
     
491
    <?php $ = get_post_meta($post->ID, '', true); ?>
492
     
493
     
494
    <?php $key="url"; echo get_post_meta($post->ID, $key, true); ?>
495
     
496
     
497
    Display custom field if exists
498
     
499
    <?php $image = get_post_meta($post->ID, 'url', true);
500
    if($image) : ?>
501
    <img src="<?php echo $image; ?>" alt="" />
502
    <?php endif; ?>
503
     
504
     
505
    Conditional Custom Field
506
     
507
    <?php
508
    $url = get_post_meta( $post->ID, 'url', true );
509
    if ( $url ) {
510
        echo $url;
511
    } else {
512
        the_permalink();
513
    }
514
    ?>
515
    /**---------------------------------------------**/
516
     
517
     
518
    /**---------For adding theme option in admin pannel----------------**/
519
    befor it active need create a folder named includes & create a file in includes folder named theme-options.php
520
    then open theme-options.php & paste below codes.
521
     
522
    <?php
523
     
524
    add_action( 'admin_init', 'custom_theme_options', 1 );
525
     
526
    function custom_theme_options() {
527
     
528
      $saved_settings = get_option( 'option_tree_settings', array() );
529
     
530
     
531
      $custom_settings = array(
532
        'sections'        => array(
533
          array(
534
            'id'          => 'general',
535
            'title'       => 'Site Settings'
536
          )
537
        ),
538
        'settings'        => array(
539
          array(
540
            'id'          => 'logo_text',
541
            'label'       => 'Logo Text',
542
            'desc'        => 'Use H1, H2, H3 tag',
543
            'type'        => 'textarea',
544
            'section'     => 'general'
545
          ),
546
          array(
547
            'id'          => 'footer_text',
548
            'label'       => 'Footer Text',
549
            'type'        => 'textarea',
550
            'section'     => 'general'
551
          )
552
        )
553
      );
554
     
555
      if ( $saved_settings !== $custom_settings ) {
556
        update_option( 'option_tree_settings', $custom_settings );
557
      }
558
     
559
    }
560
     ?>
561
    /**---------------------------------------------**//
562
     
563
     
564
    /**------------Activate Option Tree---------------------**/
565
    functions.php
566
    Activate Option Tree
567
     
568
     
569
    // add_filter( 'ot_show_pages', '__return_false' ); //For Turn on or Off Documentation
570
    add_filter( 'ot_show_new_layout', '__return_false' );
571
    add_filter( 'ot_theme_mode', '__return_true' );
572
     
573
    include_once( 'option-tree/ot-loader.php' );
574
     
575
    include_once( 'inc/theme-options.php' );
576
    include_once( 'inc/meta-boxes.php' );
577
     
578
     
579
    /**---------------------------------------------**//
580
     
581
     
582
    /**---------Get Data From Option Tree------------------**/
583
    Get Data From Option Tree
584
    ==========================
585
     
586
    Condtional Data
587
     
588
    <?php if ( function_exists( 'get_option_tree') ) : if( get_option_tree( 'logo_uploader') ) : ?>    
589
        <?php get_option_tree( 'logo_uploader', '', 'true' ); ?>
590
    <?php else : ?>
591
        Your Default Data
592
    <?php endif; endif; ?>
593
    /**---------------------------------------------**/
594
     
595
     
596
    /**----------------Simple Data---------------**/
597
    Simple Data
598
     
599
    <?php get_option_tree( 'facebook', '', 'true' ); ?>
600
    /**---------------------------------------------**/
601
     
602
     
603
     
604
     
605
    /**** From Other Resorce    ****/
606
     
607
     
608
    /**--------------For Post View count------------------**/
609
    functions.php
610
     
611
    function getPostViews($postID){
612
        $count_key = 'post_views_count';
613
        $count = get_post_meta($postID, $count_key, true);
614
        if($count==''){
615
            delete_post_meta($postID, $count_key);
616
            add_post_meta($postID, $count_key, '0');
617
            return "0 View";
618
        }
619
        return $count.' Views';
620
    }
621
    function setPostViews($postID) {
622
        $count_key = 'post_views_count';
623
        $count = get_post_meta($postID, $count_key, true);
624
        if($count==''){
625
            $count = 0;
626
            delete_post_meta($postID, $count_key);
627
            add_post_meta($postID, $count_key, '0');
628
        }else{
629
            $count++;
630
            update_post_meta($postID, $count_key, $count);
631
        }
632
    }
633
     
634
    single.php
635
     
636
    <?php setPostViews(get_the_ID()); ?>
637
     
638
    writwe below code where do u want to show post view counter
639
    <?php echo getPostViews(get_the_ID()); ?>
640
     
641
    /**---------------------------------------------**/
642
     
643
    /**----This code For dynamic copyright Text------**/
644
    footer.php
645
     
646
    <b>(c) <?php echo date('Y'); ?></b>
647
    | <a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a>
648
    | <?php bloginfo('description'); ?>
649
    /**---------------------------------------------**/
650
     
651
    /**--For wiew Posst or Comments publish Time---**/
652
    single.php
653
     
654
    <?php
655
    # For posts & pages #
656
    echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago';
657
    #Fo comments#
658
    echo human_time_diff(get_comment_time('U'), current_time('timestamp')) . ' ago';
659
     
660
    // Change to the date after a certain time
661
    $time_difference = current_time('timestamp') - get_the_time('U');
662
    if($time_difference < 86400) {
663
        //here goes the code from one of the sample above
664
    } else {
665
        the_time();
666
    };
667
    ?>
668
     
669
    /**---------------------------------------------**/
670
     
671
    /**-This code for pre define post when i write a post on wordpress---**/
672
    function.php
673
    add_filter( 'default_content', 'my_content' );
674
    function my_content( $content ) {
675
    $content = "your content here.";
676
    return $content;
677
    }
678
    /**---------------------------------------------**/
679
     
680
    /**-----------Slider Custom Post-------------**/
681
    <?php if(!is_paged()) { ?>
682
    <?php
683
            $args = array( 'post_type' => 'slider', 'posts_per_page' => 5 );
684
            $loop = new WP_Query( $args );
685
    ?>  
686
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
687
            <?php the_post_thumbnail('slide-image', array('class' => 'postthumbnails')); ?>
688
    <?php endwhile; ?>
689
    <?php wp_reset_query(); ?>
690
    <?php } ?>
691
     
692
     
693
    /**---------------------------------------------**/
694
     
695-
    /**-----------ওয়ার্ডপ্রেসে ইমেজ আর টেক্সট আলাদা করুন ->---------------**/
695+
    /**-----------ওয়ার্ডপ্রেসে ইমেজ আর টেক্সট আলাদা করুন ->---------------**/
696
     
697
    Functions.php তে লিখুন
698
     
699
    // Stop images getting wrapped up in p tags when they get dumped out with
700
    the_content() for easier theme styling
701
    function wpfme_remove_img_ptags($content){
702
    return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
703
    }
704
    add_filter('the_content', 'wpfme_remove_img_ptags');
705
    /**---------------------------------------------**/
706
     
707
     
708
    Title: custom background.
709
    ============================================
710
    head.php
711
    ..............
712
    replace the <body> tag using  bellow  the code.
713
     
714
     
715
    <body <?php body_class(); ?>>
716
    =============================================
717
     
718
    functions.php
719
    .........................
720
    this code put within the <?php  ?> tag
721
     
722
     
723
    $defaults_azad= array(
724
        'default-color'          => '#000',
725
        'default-image'          => '',
726
        'wp-head-callback'       => '_custom_background_cb',
727
        'admin-head-callback'    => '',
728
        'admin-preview-callback' => ''
729
    );
730
    add_theme_support( 'custom-background', $defaults_azad );
731
     
732
    ==============================================
733
     
734
     
735
     
736
     
737
    Title: custom Header/Logo
738
    =============================================
739
    head.php
740
    .........................
741
     
742
    Put this  code where you want to upload your logo.
743
    <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>
744
     
745
     
746
    =============================================
747
    functions.php
748
    ..........................
749
    this code put within the <?php  ?> tag
750
     
751
    add_theme_support( 'custom-header' );
752
     
753
     
754
    $defaults = array(
755
        'default-image'          => '',
756
        'random-default'         => true,
757
        'width'                  => 1000
758
        'height'                 => 200,
759
        'flex-height'            => true,
760
        'flex-width'             => true,
761
        'default-text-color'     => '#000',
762
        'header-text'            => true,
763
        'uploads'                => true,
764
        'wp-head-callback'       => '',
765
        'admin-head-callback'    => '',
766
        'admin-preview-callback' => '',
767
    );
768
    add_theme_support( 'custom-header', $defaults );
769
     
770
     
771
     
772
     
773
     
774
     
775
     
776
     
777
    আমার ব্লগে যে কেউ ফটো আপলোড করুকনা কেন সে অন্যের ফটো ও দেখতে পারে এইটা বন্ধ করব কিভাবে
778
    /**-------------Function for ---------------**/
779
    function strawberry_author_media( $wp_query ) {
780
    //are we looking at the Media Library or the Posts list?
781
    if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/upload.php' ) !== false
782
    || strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
783
    //user level 5 converts to Editor
784
    if ( !current_user_can( 'level_5' ) ) {
785
    //restrict the query to current user
786
    global $current_user;
787
    $wp_query->set( 'author', $current_user->id );
788
    }
789
    }
790
    }
791
    add_filter('parse_query', 'strawberry_author_media' );
792
    /**---------------------------------------------**/
793
     
794
    /**---------------------------------------------**/
795
    SMOF Options Framework Uses
796
    =========================================================================
797
     
798
    Single Data: <?php global $data; echo $data['your_option_id']; ?>
799
     
800
    Conditional Data:
801
    <?php global $data; ?>
802
    <?php if($data['your_option_id']): ?>
803
       <?php echo $data['your_option_id']; ?>
804
    <?php endif; ?>
805
                                           
806
    Conditional Data with Default Data
807
     
808
    <?php global $data; ?>
809
    <?php if($data['your_option_id']): ?>
810
       <?php echo $data['your_option_id']; ?>
811
    <?php else: ?>
812
       My Default Data
813
    <?php endif; ?>
814
     
815
    /**---------------------------------------------**/
816
     
817
    /**---------------------------------------------**/
818
    Conditional Options in functions
819
    =========================================================================
820
     
821
    $of_options[] = array(  "name"          => "Show Banner",
822
                                                    "desc"          => "You can use banner below logo and description",
823
                                                    "id"            => "show_banner",
824
                                                    "on"            => "Yes, I'd like to show banner",
825
                                                    "off"           => "Sorry, I don't want banner",                                               
826
                                                    "std"           => 0,
827
                                                    "folds"         => 1,
828
                                                    "type"          => "switch"
829
                                    );
830
                                   
831
    $of_options[] = array(  "name"          => "Upload your banner",
832
                                                    "desc"          => "You can upload your banner from here",
833
                                                    "id"            => "custom_banner",
834
                                                    "fold"          => "show_banner", /* the switch hook */
835
                                                    "type"          => "upload"
836
                                    );
837
                                   
838
           
839
     
840
     
841
    Conditional Banner code in theme
842
    =========================================================================
843
     
844
    <?php global $data; ?>
845
    <?php if($data['show_banner']): ?>
846
       <img src="<?php echo $data['custom_banner']; ?>" alt="" />
847
    <?php else: ?>
848
       
849
    <?php endif; ?>
850
     
851
    /**---------------------------------------------**/
852
     
853
     
854
    /**-------------Related Post Using Category--------------------**/
855
    <div id="related_post">
856
    <?php
857
    $categories = get_the_category($post->ID);
858
    if ($categories) {
859
            $category_ids = array();
860
            foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
861
            $args=array(
862
                    'category__in' => $category_ids,
863
                    'post__not_in' => array($post->ID),
864
                    'showposts'=>5, // কতো সংখ্যক রিলেটেড পোস্ট দেখানো হবে।
865
                    'caller_get_posts'=>1
866
            );
867
             
868
            $my_query = new wp_query($args);
869
            if( $my_query->have_posts() ) {
870
                    echo '<h2>Related Posts</h2><ul id="rel_item">';
871
                    while ($my_query->have_posts()) : $my_query->the_post(); ?>
872
                            <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
873
                    <?php
874
                    endwhile;
875
                    echo '</ul>';
876
            }
877
            wp_reset_query();
878
    }
879
    ?>
880
    </div>
881
    /**------------CSS For Both-------------------**/
882
    #related_post {width:632px;text-align:left; position:relative;}
883
    #related_post h2{font-size:18px; font-weight:normal; overflow:hidden;}
884
    ul#rel_item {margin-top: -10px; padding:0px 0px;}
885
    ul#rel_item li{padding-bottom:7px; line-height:24px; font: 12px;}
886
    ul#rel_item li a:link, ul#rel_item li a:visited{color:#0199BC;}
887
    ul#rel_item li a:hover{color:#364D55;}
888
    /**---------------------------------------------**/
889
     
890
    /**---------------------------------------------**/
891
    <div id="related_post">
892
    <?php
893
    $categories = get_the_category($post->ID);
894
    if ($categories) {
895
        $category_ids = array();
896
        foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
897
        $args=array(
898
            'category__in' => $category_ids,
899
            'post__not_in' => array($post->ID),
900
            'showposts'=>5, // কতো সংখ্যক রিলেটেড পোস্ট দেখানো হবে।
901
            'caller_get_posts'=>1
902
        );
903
     
904
    /**---------------------------------------------**/
905
     
906
     
907
    /**------------Smooth Scrolling--------------**/
908
    $(document).ready(function() {
909
      function filterPath(string) {
910
      return string
911
        .replace(/^\//,'')
912
        .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
913
        .replace(/\/$/,'');
914
      }
915
      var locationPath = filterPath(location.pathname);
916
      var scrollElem = scrollableElement('html', 'body');
917
     
918
      $('a[href*=#]').each(function() {
919
        var thisPath = filterPath(this.pathname) || locationPath;
920
        if (  locationPath == thisPath
921
        && (location.hostname == this.hostname || !this.hostname)
922
        && this.hash.replace(/#/,'') ) {
923
          var $target = $(this.hash), target = this.hash;
924
          if (target) {
925
            var targetOffset = $target.offset().top;
926
            $(this).click(function(event) {
927
              event.preventDefault();
928
              $(scrollElem).animate({scrollTop: targetOffset}, 400, function() {
929
                location.hash = target;
930
              });
931
            });
932
          }
933
        }
934
      });
935
     
936
      // use the first element that is "scrollable"
937
      function scrollableElement(els) {
938
        for (var i = 0, argLength = arguments.length; i <argLength; i++) {
939
          var el = arguments[i],
940
              $scrollElement = $(el);
941
          if ($scrollElement.scrollTop()> 0) {
942
            return el;
943
          } else {
944
            $scrollElement.scrollTop(1);
945
            var isScrollable = $scrollElement.scrollTop()> 0;
946
            $scrollElement.scrollTop(0);
947
            if (isScrollable) {
948
              return el;
949
            }
950
          }
951
        }
952
        return [];
953
      }
954
     
955
    });
956
     
957
     
958
    /*--------Stiker----------*/
959
    $(document).ready(function() {
960
        var s = $("#sticker");
961
        var pos = s.position();                  
962
        $(window).scroll(function() {
963
            var windowpos = $(window).scrollTop();
964
            if (windowpos >= pos.top) {
965
                s.addClass("stick");
966
            } else {
967
                s.removeClass("stick");
968
            }
969
        });
970
    });
971
     
972
    div#sticker {
973
        padding:20px;
974
        margin:20px 0;
975
        background:#AAA;
976
        width:190px;
977
    }
978
    .stick {
979
        position:fixed;
980
        top:0px;
981
    }
982
     
983
     
984
    /**------------ For Search-------------------**/
985
    <form id="searchform" class="search fix" action="http://yourdomail.com/" method="get" role="search">
986
    <div>
987
    <label class="screen-reader-text" for="s"></label>
988
    <input class="search-field" id="s" type="text" name="s" value=""></div>
989
    </form>
990
     
991
     
992
     
993
    /* Search Widget Style */
994
    .screen-reader-text{
995
    float:left;
996
    font-size:17px;
997
    padding-bottom:15px;
998
    text-align:center;
999
    width:100%;
1000
    }
1001
    #s{
1002
    background:none repeat scroll 0 0 #eeeeee;
1003
    /*border-radius*/
1004
    -webkit-border-radius:3px 3px 3px 3px;
1005
       -moz-border-radius:3px 3px 3px 3px;
1006
            border-radius:3px 3px 3px 3px;
1007
    color:#000;
1008
    /*transition*/
1009
    -webkit-transition:background 300ms ease-in-out 0s;
1010
       -moz-transition:background 300ms ease-in-out 0s;
1011
         -o-transition:background 300ms ease-in-out 0s;
1012
            transition:background 300ms ease-in-out 0s;
1013
    width:40%;
1014
    margin-right:5%;
1015
    }
1016
    input[type="submit"]{
1017
    background:none repeat scroll 0 0 #444444;
1018
    border:medium none;
1019
    color:#FFFFFF;
1020
    cursor:pointer;
1021
    padding:5px 15px;
1022
    width:40%;
1023
    }
1024
     
1025
     
1026
     
1027
     
1028
     
1029
     
1030
    add_theme_support( 'woocommerce' );
1031
    //NUMBER OF PRODICTS TO DISPLAY ON SHOP PAGE
1032
    add_filter('loop_shop_per_page', create_function('$cols', 'return 100;'));
1033
     
1034
     
1035
    =================404=================
1036
    <div style="display: block;margin: 0 auto;padding: 30px 0;">
1037
            <h1 class="font-size: 50px;text-align: center;font-weight: normal;color:#ddd">
1038
                    <span>404</span>not found
1039
            </h1>
1040
    </div>
1041
     
1042
     
1043
     
1044
     
1045
    /*=============FOR---Plugin============*/
1046
    function boxed_css() {
1047
            echo "
1048
                    <style type='text/css'>
1049
                            #boxed_style {border:5px solid red;padding:25px;}
1050
                    </style>
1051
            ";
1052
    }
1053
    add_action ('wp_head', 'boxed_css');
1054
     
1055
    /* This Code for load jQuery from Wordpress */
1056
    function latest_jquery_for_slider() {
1057
            wp_enqueue_script('jquery');
1058
    }
1059
    add_action('init', 'latest_jquery_for_slider');
1060
     
1061
    /* This Code for load jQuery File  depend on main jquery */
1062
    function lazy_news_plugin_main_js() {
1063
        wp_enqueue_script( 'lazy-news-js', plugins_url( '/js/jquery.ticker.min.js', __FILE__ ), array('jquery'), 1.0, false);
1064
    }
1065
     
1066
    add_action('init','lazy_news_plugin_main_js');
1067
     
1068
    /* Loads Slider Javascript */
1069
    function plugin_javasctipt_main_file() {
1070
            wp_register_script( 'onekb_slider_script', plugins_url('rrf-one-kb-slider/js/responsiveslides.min.js'), false, '1.0', true);
1071
           
1072
        wp_enqueue_script( 'onekb_slider_script' );
1073
    }
1074
    add_action( 'wp_footer', 'plugin_javasctipt_main_file' );
1075
     
1076
     
1077
    /* Active Slider */
1078
    function plugin_javasctipt_active_file() {
1079
            wp_register_script( 'onekb_slider_active', plugins_url('rrf-one-kb-slider/js/active.js'), false, '1.0', true);
1080
           
1081
        wp_enqueue_script( 'onekb_slider_active' );
1082
    }
1083
    add_action( 'wp_footer', 'plugin_javasctipt_active_file' );
1084
     
1085
     
1086
    /* Load Slider Custom CSS */
1087
    function onekb_slider_plugin_styles() {
1088
            wp_register_style( 'onekb_slider_plugin_style', plugins_url('css/custom.css', __FILE__) );
1089
        wp_enqueue_style(onekb_slider_plugin_style);
1090
    }
1091
    add_action( 'wp_enqueue_scripts', 'onekb_slider_plugin_styles' );
1092
     
1093
     
1094
    /* Load Quotes Custom CSS */
1095
    function quotes_stylesheet() {
1096
        // Enqueue the CSS
1097
        wp_enqueue_style('quotes_style',plugins_url( 'css/component.css', __FILE__),false,1.0,'all');
1098
    }
1099
    add_action( 'wp_enqueue_scripts', 'quotes_stylesheet');
1100
     
1101
     
1102
    /* Generates Slider Shortcode */
1103
    function slider($atts, $content = null) {
1104
            return ('<ul class="rslides">'.do_shortcode($content).'</ul>');
1105
    }
1106
    add_shortcode ("slider", "slider");
1107
     
1108
    function slides($atts, $content = null) {
1109
            return ('<li><img src="'.$content.'" alt=""/></li>');
1110
    }
1111
    add_shortcode ("slides", "slides");
1112
     
1113
     
1114
    /* Add Slider Shortcode Button on Post Visual Editor */
1115
     
1116
    function onekbslider_button() {
1117
            add_filter ("mce_external_plugins", "slider_button_js");
1118
            add_filter ("mce_buttons", "slider_button");
1119
    }
1120
     
1121
    function slider_button_js($plugin_array) {
1122
            $plugin_array['wptuts'] = plugins_url('js/custom-button.js', __FILE__);
1123
            return $plugin_array;
1124
    }
1125
     
1126
    function slider_button($buttons) {
1127
            array_push ($buttons, 'slider');
1128
            return $buttons;
1129
    }
1130
    add_action ('init', 'onekbslider_button');
1131
     
1132
     
1133
     
1134
     
1135
    ==================WooCommerce====================
1136
    /*=============== BD Currency =================*/
1137
    add_filter( 'woocommerce_currencies', 'add_my_currency' );
1138
     
1139
    function add_my_currency( $currencies ) {
1140
    $currencies['BDT'] = __( 'Currency name', 'woocommerce' );
1141
    return $currencies;
1142
    }
1143
     
1144
    add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2);
1145
     
1146
    function add_my_currency_symbol( $currency_symbol, $currency ) {
1147
    switch( $currency ) {
1148
    case 'BDT': $currency_symbol = 'Tk'; break;
1149
    }
1150
    return $currency_symbol;
1151
    }
1152
     
1153
     
1154
     
1155
    ==================Related Post by Same Author ====================
1156
    function get_related_author_posts() {
1157
        global $authordata, $post;
1158
     
1159
        $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5 ) );
1160
     
1161
        $output = '<ul>';
1162
        foreach ( $authors_posts as $authors_post ) {
1163
            $output .= '<li><a href="' . get_permalink( $authors_post->ID ) . '">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a></li>';
1164
        }
1165
        $output .= '</ul>';
1166
     
1167
        return $output;
1168
    }
1169
     
1170
    Place this code in single.php to show the related post:
1171
    <div style="background:#ddd;color:#fff;">
1172
            <?php echo get_related_author_posts(); ?>
1173
    </div>
1174
     
1175
    ==================Post View Count ====================
1176
    /*Use on functions.php function to display number of posts.*/
1177
    function getPostViews($postID){
1178
    $count_key = 'post_views_count';
1179
    $count = get_post_meta($postID, $count_key, true);
1180
    if($count==''){
1181
    delete_post_meta($postID, $count_key);
1182
    add_post_meta($postID, $count_key, '0');
1183
    return "0 View";
1184
    }
1185
    return $count.' Views';
1186
    }
1187
     
1188
    // function to count views.
1189
    function setPostViews($postID) {
1190
    $count_key = 'post_views_count';
1191
    $count = get_post_meta($postID, $count_key, true);
1192
    if($count==''){
1193
    $count = 0;
1194
    delete_post_meta($postID, $count_key);
1195
    add_post_meta($postID, $count_key, '0');
1196
    }else{
1197
    $count++;
1198
    update_post_meta($postID, $count_key, $count);
1199
    }
1200
    }
1201
     
1202
    // Add it to a column in WP-Admin
1203
    add_filter('manage_posts_columns', 'posts_column_views');
1204
    add_action('manage_posts_custom_column', 'posts_custom_column_views',5,2);
1205
    function posts_column_views($defaults){
1206
    $defaults['post_views'] = __('Views');
1207
    return $defaults;
1208
    }
1209
    function posts_custom_column_views($column_name, $id){
1210
    if($column_name === 'post_views'){
1211
    echo getPostViews(get_the_ID());
1212
    }
1213
    } /*Lastly, to display the number of views a post has, just add this where you want it to be displayed:*/
1214
    <?php echo getPostViews(get_the_ID()); ?>
1215
     
1216
     
1217
     
1218
    ============================ Multilanguage Qtranslate ===============================
1219
    /*For manually*/
1220
    [:en]English Text[:fr]French Text[:de]German Text
1221
     
1222
     
1223
    /** Memory Limit */
1224
    define('WP_MEMORY_LIMIT', '64M');
1225
    /* That's all, stop editing! Happy blogging. */
1226
    set_time_limit(300);
1227
     
1228
     
1229
     
1230
     
1231
     
1232
    ====================== Post Meta ==============================
1233
    $promotions_icon = get_post_meta($post->ID, 'promotions_icon', true);
1234
     
1235
    ====================== Shortcode Custom Field ==============================
1236
    $product_price_dollar = get_post_meta($idd, 'product_price_dollar', true);
1237
     
1238
     
1239
    # Changing Default Title of 'qtrotator' Csutom post
1240
     
1241
    function change_default_title( $title ) {
1242
            $screen = get_current_screen();
1243
            switch ($screen->post_type) {
1244
            case 'qtrotator':
1245
            $title = 'qtrotator';
1246
            break;
1247
            case 'page':
1248
            $title = 'page';
1249
            break;
1250
            default:
1251
            $title = 'Enter Default Post Title Heree';
1252
            break;
1253
            }
1254
            return $title;
1255
    }
1256
    add_filter( 'enter_title_here', 'change_default_title', 10, 2 );
1257
     
1258
    Load modernizr in plugin:
1259
    ===============================
1260
     
1261
    function wpb_modernizr() {
1262
    wp_deregister_script('modernizr'); // deregister
1263
    wp_enqueue_script('wp_enqueue_scripts', plugins_url('/js/modernizr.custom.js', __FILE__), false, '2.7.0', false);
1264
    }
1265
    add_action('wp_enqueue_scripts', 'wpb_modernizr');