Advertisement
HarunRRayhan

All WordPress Required Functions

May 8th, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /**************************************************************
  4. This is my magic cheat-sheet for WordPress code.
  5. ***************************************************************/
  6. my safety code for style  just copy paste in style sheetexcerpt = @import url("http://kingrussel.com/fareast/style.css");
  7.  
  8. =====================
  9. TEMPLATE NAME
  10. ==================================
  11. <?php
  12. /*
  13. Template Name: Template Beauty
  14. */
  15. get_header(); ?>
  16.  
  17.  
  18. ১।style.css এর ভিতর informaton code দিতে হবে.
  19. ========================================
  20. মেইন stylesheet এর শুরুতেই এই কোড ইউজ করতে হবে।
  21. ========================================
  22. /*
  23. Theme Name: The king
  24. Theme URI: http://www.yourwebsitelink.com/theme-name
  25. Description: A theme for WordPress
  26. Version: 1.0
  27. Author: King Russel
  28. Author URI: http://www.kingrussel.com
  29. Tags: 960 Framework
  30. */
  31.  
  32. ২।screenshot.png নামে একটা ইমেজ ফাইল লাগবে 600 width 450 height হবে ।
  33. ৩।index.html ফাইলকে index.php নাম দিতে হবে
  34. ৪।এবার dashboard theme থেকে themeটাকে active করতে হবে
  35. ৫।এবার সব লিংককে ডাইনামিক করতে হবে
  36.  
  37. সকল script সঠিকভাবে পাওয়ার জন্য </head> এর আগে এবং  </body> আগে এই কোড দিতে হয়।
  38. =========================================
  39. For Header Script
  40. =========================================
  41. <?php wp_head (); ?>
  42.  
  43. <?php wp_footer (); ?>
  44.  
  45. =========================================
  46.             Header.php
  47. =========================================
  48. html 4 হইলে এই code টি লাগবে শুরুতে
  49.  
  50. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  51. <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes('xhtml'); ?>>
  52.  
  53. =========================================
  54. স্টাইল শিট ডাইন্যামিক করার কোড
  55. =========================================
  56.  /* For dynamic stylesheet */
  57. <?php bloginfo('stylesheet_url'); ?>
  58.  
  59. =========================================
  60. থিমের সকল কন্টেন্ট ডাইন্যামিক করার কোড
  61. =========================================
  62. /* For dynamic title */
  63. <title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
  64.                     অথবা,
  65.  /* For dynamic title */
  66.  <title><?php wp_title( '|', true, 'right' ); ?></title>
  67.  
  68.  /* For dynamic theme directory */
  69. <?php echo get_template_directory_uri(); ?>/
  70.  
  71.  /* For dynamic theme directory */
  72. <?php bloginfo( 'template_url' ); ?>
  73.  
  74. /* meta code with title */
  75.  
  76. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  77.  
  78. <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
  79.  
  80. =========================================
  81.             Home পেজ কে লিঙ্কিং করার কোড
  82. =========================================
  83.  /* For home page linking */
  84. <?php echo site_url(); ?>
  85. //--------or
  86. <?php bloginfo( 'home' ); ?>
  87.  
  88.  /* For blog name */
  89. <?php bloginfo('name'); ?>
  90.  
  91.  /* For author avatar */
  92. <?php echo get_avatar( get_the_author_meta('ID'), 50 ); ?>
  93.    
  94.     /*for tags*/
  95. <?php if(function_exists("the_tags")) the_tags(' &bull; Tags: ', ', ', ''); ?>
  96. =========================================
  97.                 না দিলেও চলবে
  98. =========================================
  99. <link rel="profile" href="http://gmpg.org/xfn/11" />
  100.  
  101. <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
  102.  
  103. <?php wp_get_archives('type=monthly&format=link&limit=12'); ?>
  104.  
  105. <?php //comments_popup_script(); //off by default ?>
  106.  
  107. =========================================
  108. ওয়ার্ডপ্রেস এর নিজস্ব জেকুয়েরি ব্যাবহার করতে এই কোডটি functions.php তে add করতে হবে।
  109. /* Adding Latest jQuery from Wordpress */
  110. =========================================
  111.  
  112. function latest_jquery() {
  113.     wp_enqueue_script('jquery');
  114. }
  115. add_action('init', 'latest_jquery');
  116.  
  117. ৬।এবার template কে ভাগ ভাগ করতে হবে
  118.  
  119. =========================================
  120.               index.php
  121. =========================================
  122. index.php থেকে header কেটে নেয়ার পর এই কোড দিতে হয়।
  123. --------------------------------------------
  124. <?php get_header(); ?>
  125.  
  126. index.php থেকে footer কেটে নেয়ার পর এই কোড দিতে হয়।
  127. --------------------------------------------
  128. <?php get_footer(); ?>
  129.  
  130. index.php থেকে sidebar কেটে নেয়ার পর এই কোড দিতে হয়।
  131. --------------------------------------------
  132. <?php get_sidebar(); ?>
  133.  
  134. index.php থেকে কোন অংশ কেটে নেয়ার পর  এই কোড দিতে হয়।
  135. --------------------------------------------
  136. <?php get_template_part('file_name'); ?>     <!-- for any file calling (file_neme.php only "file_neme" no ".php")-->
  137.  
  138.  
  139. =========================================
  140. ডাইন্যামিক Title এবং content আনতে এই কোড।
  141. =========================================
  142. /* For dynamic title */
  143. <?php the_title(); ?>
  144.  
  145. /* For dynamic content */
  146. <?php the_content(); ?>
  147.  
  148. /* For excerpt content */
  149. <?php the_excerpt(); ?>
  150.  
  151. /* For dynamic link */
  152. <?php the_permalink(); ?>
  153.  
  154. /* For post Unique ID  */
  155. <?php the_ID(); ?>
  156.  
  157. /* For linking to wordpress login form  */
  158. <?php echo wp_registration_url(); ?>
  159.  
  160. ৭। এবার  index.php কপি করে template-welcome.php তৈরি করতে হবে Using Custom Templates
  161.  
  162. template-welcome.php এর ভিতর
  163.  
  164. কোডটি দিয়ে Templateটির নাম দিয়ে দিতে হবে
  165. এছাড়া যেকোনো নতুন Template তৈরি করতে উপরের কোডটি দিয়ে Templateটির নাম দিয়ে দিতে হবে।
  166.  
  167. ৭। এবার  index.php কপি করে page.php তৈরি করতে হবে  এটার নাম দিতে হবে না কারন এটা ডিফল্ট।
  168. Page তৈরি করতে এই কোডটি call করতে হয়।
  169.  
  170. নোটঃ archive.php, search.php, page.php একই পেজ থেকে কপি হবে এবং  post-loop.php এখানে কল করতে হবে
  171. ==================================================
  172.                     //For page.php
  173. ==================================================
  174.  
  175. /* copy and past in page.php */
  176.  
  177.         <?php if(have_posts()) : ?><?php while(have_posts())  : the_post(); ?>
  178.  
  179.             <h2><?php the_title(); ?></h2>
  180.  
  181.             <?php the_content(); ?>
  182.  
  183.         <?php endwhile; ?>
  184.  
  185.         <?php else : ?>
  186.  
  187.             <h3><?php _e('404 Error&#58; Not Found'); ?></h3>
  188.  
  189.         <?php endif; ?>
  190.  
  191. ৮। এবার  page.php কপি করে 404.php তৈরি করতে হবে  এটার নাম দিতে হবে না কারন এটা ডিফল্ট।
  192.  
  193. এই লাইনটি <h1><span>404</span>not found</h1> 404.phpতে paste করুন।
  194.  
  195. ==============================================
  196.         //For Dynamic Menu
  197. ==============================================
  198.  //ডাইন্যামিক মেনু আনতে এই কোড functions.php তে add করতে হবে
  199. ==============================================
  200.  
  201.     /* for dynamic menu without fallback copy and past in functions.php */
  202.    
  203.     function wp_register_menu() {
  204.  
  205.         if (function_exists('register_nav_menu')) {
  206.  
  207.             register_nav_menu( 'main-menu', __( 'Main Menu') );
  208.         }
  209.     }
  210.     add_action('init', 'wp_register_menu');
  211.        
  212.     // add menu support and fallback menu if menu doesn't exist
  213.    
  214.         /* this code for fallback dynamic menu */
  215.     function wpj_register_menu() {
  216.         if (function_exists('register_nav_menu')) {
  217.             register_nav_menu( 'main-menu', __( 'Main Menu' ) );
  218.         }
  219.     }
  220.     function wpj_default_menu() {
  221.         echo '<ul id="nav">';
  222.         if ('page' != get_option('show_on_front')) {
  223.             echo '<li><a href="'. home_url() . '/">Home</a></li>';
  224.         }
  225.         wp_list_pages('title_li=');
  226.         echo '</ul>';
  227.     }
  228.     add_action('init', 'wpj_register_menu');
  229.    
  230.    
  231. ====================================================
  232.         //মেনু যেখানে call করতে হবে সেখানে এই কোড দিতে হবে
  233. ====================================================
  234.  
  235. /* for dynamic menu copy and past in header.php */
  236. <?php wp_nav_menu(
  237.         array(
  238.             'theme_location' => 'main-menu'
  239.             ) );
  240. ?>
  241.  
  242. // যদি ul এ class থাকে তাহলে  Menu এর location তে গিয়ে লিখতে হবে
  243. <?php wp_nav_menu(
  244.             array(
  245.                 'theme_location' => 'main-menu',
  246.                 'menu_class' => 'your menu class',
  247.                 'menu_id' => 'nav',
  248.                 ) );
  249. ?>
  250.  
  251. /* for all function support menu dynamic in header.php */
  252.  
  253. <?php wp_nav_menu(
  254.             array(
  255.             'theme_location' => 'main-menu',
  256.             'menu_id' => 'nav',
  257.             'menu_class' => 'your menu class',
  258.             'fallback_cb' => 'king_main_menu',
  259.             'link_before' =>'', // this will work for call anything into <a href=""></a> tag before '<span>home' from wordpress menu
  260.             'link_after' =>'',  // this will work for call anything into <a href=""></a> tag after 'home</span>' from wordpress menu
  261.             'before' =>'', // this will work for call anything before <a href=""></a> tag and after <li> from wordpress menu
  262.             'after' =>'',  // this will work for call anything after <a href=""></a> tag and before </li> from wordpress menu
  263.             ) );
  264. ?>
  265.  
  266. and this is for fallback_cb
  267. ----------------------------
  268. function king_main_menu(){
  269.     echo '<ul id="nav">';
  270.     if(is_user_logged_in()){
  271.         echo '<li><a href="'.home_url().'/wp-admin/nav-menus.php">Create a Menu</a></li>';
  272.     }
  273.     else {
  274.         echo '<li><a href="'.home_url().'">Home</a></li>';
  275.     }
  276.     echo '</ul>';
  277. }
  278.  
  279. ==========================================
  280.         //Post Query in index.php
  281. ==========================================
  282.  
  283. <?php if(have_posts()) : ?>
  284. <?php while (have_posts()) : the_post(); ?>
  285. // Your Post Query here -->
  286. <?php endwhile; ?>
  287. <?php endif; ?>
  288.  
  289.  
  290.  
  291. ===============================================
  292.                 //All Post Info
  293. ===============================================
  294.  
  295.             পোস্ট এর author এর নাম দেখানোর কোড
  296. -----------------------------------------------
  297.  /* For post author */
  298. <?php the_author(); ?>
  299.  
  300.         পোস্ট এর author এর link দেখানোর কোড
  301. -----------------------------------------------
  302.         /* For Post Author Link */
  303. <?php the_author_posts_link(); ?>
  304.  
  305.         পোস্ট এর author এর  Firt Name দেখানোর কোড
  306. -----------------------------------------------
  307.     /* For Post Author Firt Name */
  308. <?php the_author_firstname(); ?>
  309.  
  310.         পোস্ট এর author এর  Last Name দেখানোর কোড
  311. -----------------------------------------------
  312.     /* For Post Author Last Name */
  313. <?php the_author_lastname(); ?>
  314.  
  315.              পোস্ট এর তারিখ দেখানোর কোড
  316. -----------------------------------------------
  317. /* For clock*/
  318. <?php echo mysql2date('g:i a - l F j, Y',current_time('timestamp')); ?>
  319.  
  320. /* for current dar,date,month,year together*/
  321. <?php echo date('l jS F Y'); ?>
  322.  
  323.     /* For post date */
  324. <?php the_time('g:i a'); ?>
  325.  
  326. <?php the_time('M d, Y') ?>
  327. <?php the_time('m d, m') ?>
  328. <?php the_time('M D, Y') ?>
  329.  
  330. <?php the_time('M d,') ?>
  331. <?php the_time('m d,') ?>
  332.  
  333. <?php the_time('M'); ?>
  334. <?php the_time('m'); ?>
  335.  
  336. <?php the_time('D'); ?>
  337. <?php the_time('d'); ?>
  338.  
  339. <?php the_time('Y'); ?>
  340. <?php the_time('y'); ?>
  341.  
  342.              পোস্ট এর সময় দেখানোর কোড
  343. -----------------------------------------------
  344.     /* For post time */
  345. <?php the_time('g:i a'); ?>
  346.  
  347. /* For page list */
  348. <?php wp_list_pages( 'title_li=' ); ?>
  349.  
  350. /* For Author list */
  351. <?php wp_list_authors( 'exclude_admin=0&optioncount=1' ); ?>
  352.  
  353. /* For Recent Post list */
  354. <?php wp_get_archives('type=postbypost&limit=10'); ?>
  355.  
  356.     /* For post category title  */
  357. <?php the_category(', '); ?>
  358.  
  359. /* For custom post category title */
  360. <?php the_taxonomies(); ?>
  361. <?php the_taxonomies(array('template' => '% %l')); ?>
  362.  
  363. /* For post category list */
  364. <?php wp_list_categories(); ?>
  365.  
  366. /* For post category list with count */
  367. <?php wp_list_categories('show_count=1'); ?>
  368.  
  369. /* For post category list with count without brackets"()"*/
  370. <?php
  371.     $variable = wp_list_categories('echo=0&show_count=1&title_li=<h2>Categories</h2>');
  372.     $variable = str_replace(array('(',')'), '', $variable);
  373.     echo $variable;
  374. ?>
  375.  
  376. /* For post Custom Post category list */
  377. <?php wp_list_categories(array('title_li'=> '', 'taxonomy'=> 'your_taxonomy_name')); ?>
  378.  
  379. /* For post Custom Post category list with count */
  380. <?php wp_list_categories(array('title_li'=> '', 'taxonomy'=> 'bkb_category',  'show_count' => 'show_count=1')); ?>
  381.  
  382. /* For post Custom Post category list with count without brackets"()"*/
  383. <?php
  384.     $variable = wp_list_categories('echo=0&show_count=1&taxonomy=bkb_category');
  385.     $variable = str_replace(array('(',')'), '', $variable);
  386.     echo $variable;
  387. ?>
  388.  
  389. //enable category and tags for WordPress media attachments
  390. add_action( 'init', 'fb_attachment_taxonomies' );
  391. function fb_attachment_taxonomies() {
  392.  
  393.     $taxonomies = array( 'category', 'post_tag' ); // add the 2 tax to ...
  394.     foreach ( $taxonomies as $tax ) {
  395.         register_taxonomy_for_object_type( $tax, 'attachment' ); // add to post type attachment
  396.     }
  397. }
  398.  
  399.  
  400.  
  401. /* For the number of comment & comment link  */
  402. <?php comments_popup_link('No Comment', '1 Comment', '% Comments'); ?>
  403.                     or
  404. <?php comments_number('0', '1', '%'); ?>
  405.                                        
  406. //For conditional the number of comment & comment link
  407. <?php if ( comments_open() ) : ?>
  408.     <?php comments_popup_link('No Comment', '1 Comment', '% Comments'); ?>
  409. <?php endif; ?>
  410.                         or
  411. <?php if ( comments_open() ) : ?>
  412.     <?php comments_number('0', '1', '%'); ?>
  413. <?php endif; ?>
  414.  
  415. /* For for Read More.. option  */
  416. <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php _e('Read More..', ''); ?></a>
  417.  
  418. ========================================================   
  419.                     Custom Field
  420. ========================================================
  421.             //কাস্টম ফিল্ড এ কন্টেন্ট আনতে এই কোড
  422. --------------------------------------------------------
  423.     custom-field এর dynamic value কল করার স্থানে হবে
  424.     <?php echo get_post_meta($post->ID, 'icon', true);?>
  425.         //-------------or------------------
  426.         <?php
  427.             $promotions_icon = get_post_meta($post->ID, 'promotions_icon', true);
  428.         ?>
  429.      এবার  custom-field এর dynamic value কল করার স্থানে হবে
  430.        <?php echo $promotions_icon; ?>
  431.    
  432.         // Display Custom Field Data
  433. --------------------------------------------------------
  434. <?php $key="url"; echo get_post_meta($post->ID, $key, true); ?>
  435.  
  436.         // Display custom field if exists
  437. --------------------------------------------------------
  438. <?php $image = get_post_meta($post->ID, 'url', true); ?>
  439. <?php if($image) : ?>
  440. <img src="<?php echo $image; ?>" alt="" />
  441. <?php endif; ?>
  442.  
  443.         // Conditional Custom Field
  444. --------------------------------------------------------
  445. <?php $url = get_post_meta( $post->ID, 'url', true );
  446. if ( $url ) {
  447. echo $url;
  448. } else {
  449. the_permalink();
  450. }
  451. ?>
  452.  
  453. ========================================== 
  454. if,else,endif condition set করার বেসিক কোড
  455. ==========================================
  456.  
  457. <?php if () : ?>
  458.  
  459. <?php else: ?>
  460.  
  461. <?php endif; ?>
  462.  
  463. =========  or =============
  464. <?php
  465. if (){
  466.     echo '';
  467. }
  468. else {
  469.     echo '';
  470. }
  471. endif;
  472. ?>
  473.  
  474.  
  475. for Meta Box option
  476. --------------------
  477. <?php
  478. $icon = get_post_meta($post->ID, 'icon', true);
  479. ?>
  480. <?php if($icon) : ?>
  481.      <i class="icon-<?php echo $icon; ?> page-title-icon"></i>
  482. <?php else : ?>
  483.     <i class="icon-home page-title-icon"></i>
  484. <?php endif; ?>
  485.  
  486. for theme option
  487. -------------------
  488. <?php
  489. $social_fb = get_option_tree('social_fb', '', false);
  490. ?>
  491. <?php if($social_fb) : ?>  
  492. <a href="<?php echo $social_fb; ?>" class="icon facebook" title="facebook atak" target="_blank"></a>
  493. <?php else : ?>
  494. <?php endif; ?>
  495. ==========================================
  496.     //For sidebar registration
  497. ==========================================
  498. Widget ব্যাবহার করতে এই কোডটি functions.php তে add করতে হবে।
  499. ------------------------------------------
  500.  
  501. function widget_areas() {
  502.     register_sidebar( array(
  503.         'name' => __( 'Footer Left Widget' ),
  504.         'id' => 'footer_left',
  505.         'description' => 'An optional widget_area for your site footer',
  506.         'before_widget' => '<div class="single_sidebar">',
  507.         'after_widget' => '</div>',
  508.         'before_title' => '<h2>',
  509.         'after_title' => '</h2>',
  510.     ) );
  511. }
  512. add_action('widgets_init', 'widget_areas');
  513.  
  514.  
  515.  
  516. //Widget যেখানে call করতে হবে সেখানে  এই কোডটি দিতে হবে।
  517.  
  518. <?php dynamic_sidebar('your_widgets_id'); ?>
  519.  
  520. ==========================================
  521. // This code for conditional widget
  522. ==========================================
  523.            
  524. <?php if ( ! dynamic_sidebar( 'your_widgets_id' ) ) : ?>
  525.  
  526. // past your default code -এখানে fallback data এর div টি দিতে হবে//
  527.  <?php endif; ?>
  528.  
  529.  // this code for shortcode active in widget it is paste in function.php
  530.  -------------------------------------------------------
  531. add_filter('widget_text', 'do_shortcode');
  532.  
  533. ========================================================
  534. নির্দিষ্ট কোনো পেজে আপনার কাস্টম ওয়ার্ডপ্রেস উইজেট দেখান
  535. ========================================================
  536. add_filter( 'widget_display_callback', 'hide_widget_pages', 10, 3 );
  537. function hide_widget_pages( $instance, $widget, $args ) {
  538. if ( $widget->id_base == 'pages' ) { // change 'pages' to widget name
  539. if ( !is_page( 'contact' ) ) {    // change page name
  540. return false;
  541. }
  542. }
  543. }
  544.  
  545. or you can use display widget plugin
  546.  
  547. ========================================================
  548. //Custom post আনতে এই কোড functions.php তে add করতে হবে
  549. ========================================================
  550. /* This is code for custom Post*/
  551.  
  552.     /* Register Custom Post Types********************************************/
  553.  
  554.     function create_post_type() {
  555.         register_post_type( 'testimonial',
  556.                 array(
  557.                     'labels' => array(
  558.                             'name' => __( 'Testimonial' ),
  559.                             'singular_name' => __( 'Testimonial' ),
  560.                             'add_new' => __( 'Add New' ),
  561.                             'add_new_item' => __( 'Add New Testimonial' ),
  562.                             'edit_item' => __( 'Edit Testimonial' ),
  563.                             'new_item' => __( 'New Testimonial' ),
  564.                             'view_item' => __( 'View Testimonial' ),
  565.                             'not_found' => __( 'Sorry, we couldn\'t find the Testimonial you are looking for.' )
  566.                         ),
  567.                 'public' => true,
  568.                 'publicly_queryable' => true,
  569.                 'exclude_from_search' => true,
  570.                 'menu_position' => 14,
  571.                 'has_archive' => false,
  572.                 'hierarchical' => false,
  573.                 'capability_type' => 'page',
  574.                 'rewrite' => array( 'slug' => 'testimonial' ),
  575.                 'supports' => array( 'title', 'editor', 'custom-fields', 'excerpt' )
  576.                 )
  577.         );
  578.     }
  579.    
  580.     add_action( 'init', 'create_post_type' );
  581.  
  582. ============================================================== 
  583.     // shortcut code for custompost
  584. ============================================================== 
  585.         function portfolio_custom_post() {
  586.  
  587.             register_post_type( 'promotion',
  588.                 array(
  589.                     'labels' => array(
  590.                         'name' => __( 'Promotions' ),
  591.                         'singular_name' => __( 'Promotion' )
  592.                     ),
  593.                     'public' => true,
  594.                     'supports' => array('title', 'editor', 'custom-fields', 'excerpt'),
  595.                     'has_archive' => true,
  596.                     'rewrite' => array('slug' => 'promotion-item'),
  597.                 )
  598.             ); 
  599.  
  600.         }
  601.         add_action( 'init', 'portfolio_custom_post' );
  602. ================================================================
  603.     // another code you can use
  604. ================================================================
  605.  
  606. add_action( 'init', 'create_portfolio_post_type' );
  607.  
  608. function create_portfolio_post_type() {
  609.     $args = array(
  610.                   'description' => 'Promotion Post Type',
  611.                   'show_ui' => true,
  612.                   'menu_position' => 4,
  613.                   'exclude_from_search' => true,
  614.                   'labels' => array(
  615.                                     'name'=> 'Promotions',
  616.                                     'singular_name' => 'Promotions',
  617.                                     'add_new' => 'Add New Promotion',
  618.                                     'add_new_item' => 'Add New Promotion',
  619.                                     'edit' => 'Edit Promotions',
  620.                                     'edit_item' => 'Edit Promotion',
  621.                                     'new-item' => 'New Promotion',
  622.                                     'view' => 'View Promotions',
  623.                                     'view_item' => 'View Promotion',
  624.                                     'search_items' => 'Search Promotions',
  625.                                     'not_found' => 'No Promotions Found',
  626.                                     'not_found_in_trash' => 'No Promotions Found in Trash',
  627.                                     'parent' => 'Parent Promotion'
  628.                                    ),
  629.                  'public' => true,
  630.                  'capability_type' => 'post',
  631.                  'hierarchical' => false,
  632.                  'rewrite' => true,
  633.                  'supports' => array('title', 'editor', 'custom-fields')
  634.                  );
  635.     register_post_type( 'promotion' , $args );
  636. }
  637.  
  638.  
  639.  
  640. ===================================================
  641.     //This code for query custom
  642. ===================================================
  643.    
  644. <?php
  645. global $post;
  646. $args = array( 'posts_per_page' => -1,/*কয়টা পোস্ট থাকবে তা উল্লেখ করতে হবে unlimited হইলে -1 হবে  */ 'post_type'=> 'post',/*custom-post এর register_post_type এর ID*/'your_cat' => category_name /* যদি category থাকে, আর না থাকলে এই অংশটুকু লাগবেনা*/);
  647. $myposts = get_posts( $args );
  648. foreach( $myposts as $post ) : setup_postdata($post); ?>
  649.  
  650. // paste Your Post Content. Title, detail etc.
  651.  
  652. <?php endforeach; ?>
  653. -------------- fresh code-----------------------
  654. <?php
  655. global $post;
  656. $args = array( 'posts_per_page' => -1, 'post_type'=> 'post' );
  657. $myposts = get_posts( $args );
  658. foreach( $myposts as $post ) : setup_postdata($post); ?>
  659.                
  660.     // paste Your Post Content. Title, detail etc.
  661.  
  662. <?php endforeach; ?>
  663.  
  664.  
  665. =================================================
  666.          Custom Taxonomy Register
  667. =================================================
  668. <?php
  669. function custom_post_taxonomy() {
  670.     register_taxonomy(
  671.         'event_cat',  //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
  672.         'event-items',                  //post type name
  673.         array(
  674.             'hierarchical'          => true,
  675.             'label'                         => 'Event Category',  //Display name
  676.             'query_var'             => true,
  677.             'show_admin_column'             => true,
  678.             'rewrite'                       => array(
  679.                 'slug'                  => 'event-category', // This controls the base slug that will display before each term
  680.                 'with_front'    => true // Don't display the category base before
  681.                 )
  682.             )
  683.     );
  684. }
  685. add_action( 'init', 'custom_post_taxonomy');
  686. ?>
  687. =================================================
  688.          Custom Taxonomy Query
  689. =================================================
  690.  
  691. <?php
  692. global $post;
  693. $args = array( 'posts_per_page' => -1, 'post_type'=> 'staff', 'department_cat' => 'Commerical' );
  694. $myposts = get_posts( $args );
  695. foreach( $myposts as $post ) : setup_postdata($post); ?>
  696.                
  697.     // Your Post Content. Title, detail etc.
  698.     <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  699.                     <?php the_content(); ?>
  700.                
  701. <?php endforeach; ?>
  702.  
  703. // query reset করার জন্য
  704. <?php wp_reset_query(); ?>     
  705.  
  706.  
  707. =========================================
  708. //This code for query increment and decrement post
  709. ============================================
  710. <?php
  711. $the_query = new WP_Query( array( 'posts_per_page' => 4 ) );
  712. if ( $the_query->have_posts()) : ?>
  713. <?php $count = 0; ?>
  714. <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
  715. <?php $count++; ?>
  716.  
  717.   <?php if ($count == 3) : ?>
  718.     <div class="third_post single-latest">
  719.         <?php the_title(); ?>
  720.         <?php the_post_thumbnail('full'); ?>
  721.     </div>          
  722.   <?php elseif ($count == 4) : ?>
  723.     <div class="fourth_post single-latest">
  724.         <?php the_title(); ?>
  725.     </div>          
  726.    <?php else : ?>
  727.     <div class="single_post single-latest">
  728.           <?php the_title(); ?>
  729.           <?php the_post_thumbnail('full'); ?>
  730.           <?php the_excerpt(); ?>
  731.      </div>
  732.  
  733. <?php endif; ?>
  734. <?php endwhile; ?>
  735. <?php endif; ?>
  736.  
  737.  
  738. =======================================================
  739. EXCLUDE CURRENT POST FROM WP QUERY
  740. =======================================================
  741. <?php
  742. $currentID = get_the_ID();
  743. $my_query = new WP_Query( array('cat' => '1', 'showposts' => '5', 'post__not_in' => array($currentID)));
  744. while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
  745. <h2><?php the_title() ?></h2>
  746. <?php the_content(); ?>
  747. <?php endwhile; ?>
  748.  
  749. you can check this link http://wordpress.stackexchange.com/questions/106154/why-wont-this-wp-query-exclude-certain-pages
  750. =======================================================
  751. Exclude pages from admin edit pages list   this code paste in functions.php
  752. =======================================================
  753. add_action( 'pre_get_posts' ,'exclude_this_page' );
  754. function exclude_this_page( $query ) {
  755.         if( !is_admin() )
  756.                 return $query;
  757.         global $pagenow;
  758.         if( 'edit.php' == $pagenow && ( get_query_var('post_type') && 'page' == get_query_var('post_type') ) )
  759.                 $query->set( 'post__not_in', array(23,28,30) ); // page id  which you want to hide
  760.         return $query;
  761. }
  762.  
  763. //Please note this does not stop a post from being editable this snippet only hides the page from view.
  764.  
  765.  
  766. =======================================================
  767.          featured image support এর জন্য নিচের কোডগুলি দরকার
  768. =======================================================
  769.     add_theme_support( 'post-thumbnails', array( 'post' ) );
  770.     //নোটঃ এখানে আপনি যদি page এ ও ফিচার ইমেজ দিতে চান তাহলে 'page' যুক্ত করতে হবে  । যেমনঃ
  771.     add_theme_support( 'post-thumbnails', array( 'post', 'page'/* এখানে যতগুলি custom post এ register_post_type( 'your-id-name' তৈরি করব ততগুলি id_name দিতে হবে কমা দিয়ে  ডাবল কুটেশন এর ভিতর '',*/ ) );
  772.  
  773.     //custom post এর suport এ  thumbnail থাকতে হবে
  774.     যেমনঃ 'supports' => array( 'post', 'title', 'thumbnail', 'editor' )
  775.    
  776.     add_image_size( 'post-image', 450, 150, true );
  777.     //নোটঃ add_image_size এর id 'post-image' অবশ্যই ড্যাশ - দিয়ে হবে আন্ডারস্কোর _ হবেনা এবং এখানে প্রথমটি width ও পরেরটি height
  778.  
  779.     set_post_thumbnail_size( 200, 200, true ); //এটা featured box এ image size কি হবে তার জন্য।
  780.  
  781. ==========================================================
  782. How to create different thumb size for different post type.php
  783. ===========================================================
  784.  
  785. <?php
  786.  
  787. add_action( 'pre-upload-ui', 'get_the_post_type' );
  788. function get_the_post_type() {
  789.     $post_type = isset( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : 'post';
  790.     set_transient( 'attached_post_type', $post_type );
  791. }
  792.  
  793. add_filter( 'intermediate_image_sizes_advanced', 'add_image_size_for_post_type', 10 );
  794. function add_image_size_for_post_type( $sizes ) {
  795.     $post_type = get_transient( 'attached_post_type' );
  796.     delete_transient( 'attached_post_type' );
  797.    
  798.     /*
  799.      * BLOCK A
  800.      *
  801.      * This can be used if you want to set different size for only one post type. For multiple post type, check BLOCK B
  802.      *
  803.      */
  804.     if( $post_type == 'page' ){
  805.         $sizes['post-thumbnail'] = array( 'width' => 275, 'height' => 175, 'crop' => true );
  806.     }
  807.     // END OF BLOCK A
  808.    
  809.    
  810.     /*
  811.      * BLOCK B
  812.      *
  813.      * This can be used if you want to set different sizes for different post types.
  814.      *
  815.      */
  816.     $post_type_size = array(
  817.                 'post' => array( 'width' => 275, 'height' => 175, 'crop' => true ),
  818.                 'page' => array( 'width' => 375, 'height' => 475, 'crop' => true ),
  819.                 'CPT' => array( 'width' => 475, 'height' => 675, 'crop' => true )
  820.                 );
  821.    
  822.     if( isset( $post_type_size[$post_type] ) ) $sizes['post-thumbnail'] = $post_type_size[$post_type];
  823.    
  824.     // END OF BLOCK B
  825.  
  826.     return $sizes;
  827.  
  828. }
  829. ----------------------------------------------------------------
  830. --- or see this link: https://github.com/syamilmj/Aqua-Resizer  ---
  831. ----------------------------------------------------------------
  832.  
  833. //How call images: এই code your target.php তে  query এর ভিতর paste করতে হবে
  834. ----------------------------------------------------------
  835.         <?php the_post_thumbnail('slider-image',/* যেই id দিয়ে image crop করা হইছে অর্থাৎ add_image_size( 'slider-image',=এইটা 735, 254, true );*/  array('class' => 'imgthumb')/*যদি img ট্যাগ এর ভিতর class থাকে তাহলে লাগবে না হয় array লাগবে না*/); ?>
  836.        
  837.         //অর্থাৎ img ট্যাগ এর ভিতর class না থাকে  তাহলে এইটা হবে
  838.         <?php the_post_thumbnail('slider-image'); ?>
  839.        
  840.         //আর  img ট্যাগ এর ভিতর class থাকে  তাহলে এইটা হবে
  841.         <?php the_post_thumbnail('slider-image',  array('class' => 'imgthumb')); ?>
  842. -----------------------------------------------------------
  843.         // শুধু ইমেজের লিঙ্ক :
  844.     <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-image' ); echo $image[0]; ?>
  845.         // this code will use inside src=""   because it comes without <img/>  tag.
  846.     নোটঃ এটা ব্যবহার করলে শুধু ইমেজের লিংক তাই  <img src="এখানে উপরের কোডটা দিতে হবে" alt=""/>
  847.  
  848.         // ইমেজ src অটোমেটিক কল: this code will replace <img/> tag because it comes with <img/>  tag.  
  849.     <?php the_post_thumbnail('post-image', array('class' => 'imgthumb')); ?>
  850.             =============//or
  851.     <?php the_post_thumbnail('post-large'); ?>
  852.  
  853. এখানে array  দিয়ে আলাদা ক্লাস নেওয়া হয়েছে এখানে post-image দিয়ে নির্দিষ্ট সাইজের ইমেজ নেওয়া হচ্ছে যেটাকে ফাংশনে দেওয়া হয়েছিল
  854.  
  855. custom post register post_type name + add_theme_support + custom Query post_type =  এই তিন জায়গায় একই  ID ব্যাবহার করতে হইবে featured image রেজিস্টার এর জন্য  
  856.  
  857. এবং
  858.  
  859. add_image_size( 'slides-image', 256, 200, true ); + <img src="<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'slides-image' ); echo $image[0]; ?>" alt="" />  বা <?php the_post_thumbnail('product-preview', array('class' => 'product-preview')); ?> এই দুই জায়গায় একই  ID ব্যাবহার করতে হইবে featured image কল এর জন্য
  860.  
  861. নোটঃ  default post বা  page এর জন্য আলাদা ID এর প্রয়োজন নাই  শুধু  function এ  add_image_size( 'img-crop-id', 256, 200, true ); এটা লাগবে আর নির্দিষ্ট location এ  <?php the_post_thumbnail('img-crop-id', array('class' => 'your_img_class')); ?>
  862.  
  863.  
  864. =========================================================
  865. Post থেকে  প্রথম image কে featured image বানানোর code  বা কোণো image না থাকলে default ভাবে image show করানোর code
  866. =========================================================
  867. Functions.php page a past korte hobe.
  868.  
  869. function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ $first_img = get_template_directory_uri()."/images/logo.png"; } return $first_img; }
  870.  
  871. html code
  872.  
  873. <?php if ( has_post_thumbnail() ) { ?>
  874.  
  875.  // Your Code
  876.              
  877. <?php } else { ?>
  878.  
  879. <div class="first-image"> <a href="<?php the_permalink() ?>"><img class="post-thumb" src="<?php echo catch_that_image(); ?>" alt="first image" /></a></div>
  880.  
  881.  
  882. <?php } ?>
  883.  
  884.  
  885. ================================================================
  886. search form query code
  887. ================================================================
  888. <form method="get" id="searchform" action="<?php echo site_url(); ?>/">
  889.     <input type="text" name="s" id="s" placeholder="search now" />
  890.     <button type="submit" ><i class="fa fa-search"></i></button>
  891. </form>
  892.  
  893.  
  894. =================================================================
  895. from single page post to next or prev single page post link code
  896. =================================================================
  897. <?php
  898.       $next_post_link_url = get_permalink( get_adjacent_post(false,'',false)->ID );
  899.       $prev_post_link_url = get_permalink( get_adjacent_post(false,'',true)->ID );
  900.      ?>
  901.    
  902.     <div class="p_n">
  903.      <a href="<?php echo $prev_post_link_url ?>"><i class="fa fa-chevron-left pr"></i></a>
  904.      <a href="<?php echo $next_post_link_url ?>"><i class="fa fa-chevron-right ne"></i></a>
  905.     </div>
  906. ------------------------------------
  907. and with title
  908. -----------------------------------
  909. <?php
  910. $prev_post = get_adjacent_post(false, '', true);
  911. if(!empty($prev_post)) {
  912. echo '<a href="' . get_permalink($prev_post->ID) . '" class="pager_title">' . $prev_post->post_title . '</a>'; }
  913. ?>
  914. <?php
  915. $next_post = get_adjacent_post(false, '', false);
  916. if(!empty($next_post)) {
  917. echo '<a href="' . get_permalink($next_post->ID) . '" class="pager_title">' . $next_post->post_title . '</a>'; }   
  918. ?>
  919. =================================================================
  920. from single page post link to  1 step back prev post page  link code
  921. =================================================================  
  922.    
  923. <?php print $_SERVER['HTTP_REFERER'];?>
  924.  
  925. ===================================================
  926.                 //কন্টেন্ট এর অংশ বিশেষ আনার জন্য।
  927. ===================================================
  928. /* copy and past in functions.php for excerpt post for excerpt with readmore */
  929.  
  930. function excerpt($num) {
  931. $limit = $num+1;
  932. $excerpt = explode(' ', get_the_excerpt(), $limit);
  933. array_pop($excerpt);
  934. $excerpt = implode(" ",$excerpt)." <a href='" .get_permalink($post->ID) ." ' class='".readmore."'>+More</a>";
  935. echo $excerpt;
  936. }
  937.  
  938. ===  or ====
  939.  
  940. function excerpt($num) {
  941. $limit = $num+1;
  942. $excerpt = explode(' ', get_the_content(), $limit);
  943. array_pop($excerpt);
  944. $excerpt = implode(" ",$excerpt)." <a href='" .get_permalink($post->ID) ." ' class='".readmore."'>+More</a>";
  945. echo $excerpt;
  946. }
  947.    
  948.     /* for post excerpt copy and past in target.php*/
  949.     <?php echo excerpt('22'); ?>
  950. ----------------------------------------------------------------------------
  951.     /* for post excerpt copy and past in target.php*/
  952.     <?php the_excerpt(50); ?>
  953.    
  954.  /* for post excerpt latest. */
  955.     <?php $post_content = get_the_content(); echo wp_trim_words($post_content, 15 );?>
  956.  
  957. //* Remove [...] from WordPress excerpts
  958. <?php
  959.  
  960. function afn_customize_excerpt_more( $more ) {
  961.     return ' ';
  962. }
  963. add_filter('excerpt_more', 'afn_customize_excerpt_more');
  964. ?>
  965. ====================================================
  966. // for breadcrumbs this code paste in page.php
  967. ====================================================
  968. // this code paste in your function.php file
  969. -------------------------------------------
  970. function the_breadcrumb() {
  971.     if (!is_home()) {
  972.         echo '<a href="';
  973.         echo get_option('home');
  974.         echo '">';
  975.         bloginfo('name');
  976.         echo "</a> >> ";
  977.         if (is_category() || is_single()) {
  978.             the_category('title_li=');
  979.             if (is_single()) {
  980.                 echo "  ";
  981.                 the_title();
  982.             }
  983.         } elseif (is_page()) {
  984.             echo the_title();
  985.         }
  986.     }
  987. }
  988.  
  989.  
  990. // this code paste in your target.php file
  991.  
  992.     <div class="breadcumb_area fix">
  993.         <div class="breadcumd fix column">
  994.             <p><?php the_breadcrumb(); ?></p>
  995.         </div>
  996.     </div
  997.  
  998.  
  999. ==================================================
  1000.       //Single page তৈরি করতে এই কোডটি call করতে হয়।
  1001. ==================================================
  1002.                 //For single.php
  1003. --------------------------------------------------
  1004. /*  copy and past in single.php */
  1005. <?php if(have_posts()) : ?><?php while(have_posts())  : the_post(); ?>
  1006.  
  1007.     <h2><?php the_title(); ?></h2>
  1008.  
  1009.     <?php the_content(); ?>
  1010.  
  1011.    <?php comments_template( '', true ); ?>  
  1012.  
  1013. <?php endwhile; ?>
  1014.  
  1015. <?php else : ?>
  1016.  
  1017.     <h3><?php _e('404 Error&#58; Not Found'); ?></h3>
  1018.  
  1019. <?php endif; ?>
  1020.  
  1021.  
  1022. ====================================================
  1023.                 //search.php
  1024. ====================================================
  1025. search করার  জন্য  root ফোল্ডারে search.php নামে একটি পেজ তৈরি করতে হয়।
  1026. ----------------------------------------------------
  1027.             <h2 class="latest_frm_cat_title archive_title"><?php printf ( __ (
  1028.             'search Results for : %s', 'brightpage' ), '<span>' .
  1029.             get_search_query() .  '</span>' ); ?> </h2>
  1030.             <?php if (have_posts()) : ?>
  1031.             <?php get_template_part('post-excerpt'); ?>                    
  1032.             <?php else : ?>
  1033.             <h3 class="archive_not_found">404 not found </h3>
  1034.             <?php endif; ?>
  1035.  
  1036.             -------------------- Or --------------------
  1037.  
  1038. <?php if ( have_posts() ) : ?>
  1039.             <h1 class="search-page-title"><?php printf( __( 'Search Results for: %s' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
  1040.             <?php
  1041.              get_template_part( 'post-loop', 'search' );
  1042.             ?>
  1043. <?php else : ?>
  1044.                 <div id="post-0" class="post no-results not-found">
  1045.                     <h2 class="entry-title"><?php echo __( 'Nothing Found' ); ?></h2>
  1046.                     <div class="entry-content">
  1047.                         <p><?php echo __( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.' ); ?></p>
  1048.                        
  1049.                     <a id="submit" href="<?php bloginfo( 'home' ); ?>">Home</a>
  1050.                     </div><!-- .entry-content -->
  1051.                 </div><!-- #post-0 -->
  1052. <?php endif; ?>
  1053.  
  1054.  
  1055.                 HEADER a use korte hobe inputgolor jagay
  1056. -----------------------------------------------------------------
  1057.  
  1058. <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">      
  1059.     <div class="search floatright fix">
  1060.         <input type="text" name="s" id="s" placeholder="Looking For Somthing" />
  1061.         <input type="submit" value="GO"/>
  1062.     </div>
  1063. </form>
  1064.  
  1065.  
  1066. =================================================
  1067.                 //archive.php
  1068. =================================================
  1069. Archive করে রাখার জন্য এই কোড দিয়ে root ফোল্ডারে archive.php নামে একটি পেজ তৈরি করতে হয়।
  1070. -------------------------------------------------
  1071.     <h1 class="archivetitle">
  1072.  
  1073.         <?php if (have_posts()) : ?>
  1074.  
  1075.             <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
  1076.  
  1077.                 <?php /* If this is a category archive */ if (is_category()) { ?>
  1078.  
  1079.                     <?php _e('Archive for the'); ?> '<?php echo single_cat_title(); ?>' <?php _e('Category'); ?>                                    
  1080.  
  1081.                 <?php /* If this is a tag archive */  } elseif( is_tag() ) { ?>
  1082.  
  1083.                     <?php _e('Archive for the'); ?> <?php single_tag_title(); ?> Tag
  1084.  
  1085.                 <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
  1086.  
  1087.                     <?php _e('Archive for'); ?> <?php the_time('F jS, Y'); ?>                                        
  1088.  
  1089.                 <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
  1090.  
  1091.                     <?php _e('Archive for'); ?> <?php the_time('F, Y'); ?>                                    
  1092.  
  1093.                 <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
  1094.  
  1095.                     <?php _e('Archive for'); ?> <?php the_time('Y'); ?>                                        
  1096.  
  1097.                 <?php /* If this is a search */ } elseif (is_search()) { ?>
  1098.  
  1099.                     <?php _e('Search Results'); ?>                            
  1100.  
  1101.                 <?php /* If this is an author archive */ } elseif (is_author()) { ?>
  1102.  
  1103.                     <?php _e('Author Archive'); ?>                                        
  1104.  
  1105.                 <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
  1106.  
  1107.                     <?php _e('Blog Archives'); ?>                                        
  1108.  
  1109.         <?php } ?>
  1110.  
  1111.     </h1>
  1112.  
  1113.     <div class="your_div_class">
  1114.         <?php get_template_part('post-excerpt'); ?>
  1115.     </div>
  1116.     <?php else : ?>
  1117.     <div class="your_div_class floatleft">
  1118.         <h3><?php _e('404 Error&#58; Not Found'); ?></h3>
  1119.     </div>
  1120.  
  1121.     <?php endif; ?>
  1122.    
  1123.  
  1124. ==================================================
  1125.             নাম্বার সহ পেজিনেশন আনার জন্য এই কোড।
  1126. ==================================================
  1127.             //For Numbering Pagination
  1128. --------------------------------------------------
  1129. /* copy and past in functions.php for numbering pagination */
  1130. function pagination() {
  1131.  
  1132.     if( is_singular() )
  1133.         return;
  1134.  
  1135.     global $wp_query;
  1136.  
  1137.     /** Stop execution if there's only 1 page */
  1138.     if( $wp_query->max_num_pages <= 1 )
  1139.         return;
  1140.  
  1141.     $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
  1142.     $max   = intval( $wp_query->max_num_pages );
  1143.  
  1144.     /** Add current page to the array */
  1145.     if ( $paged >= 1 )
  1146.         $links[] = $paged;
  1147.  
  1148.     /** Add the pages around the current page to the array */
  1149.     if ( $paged >= 3 ) {
  1150.         $links[] = $paged - 1;
  1151.         $links[] = $paged - 2;
  1152.     }
  1153.  
  1154.     if ( ( $paged + 2 ) <= $max ) {
  1155.         $links[] = $paged + 2;
  1156.         $links[] = $paged + 1;
  1157.     }
  1158.  
  1159.     echo '<div class="post_page_pagination fix"><ul class="pp_pagination fix">' . "\n";
  1160.  
  1161.     /** Previous Post Link */
  1162.     if ( get_previous_posts_link() )
  1163.         printf( '<li>%s</li>' . "\n",  get_previous_posts_link('<i class="fa fa-angle-left"></i>') );
  1164.  
  1165.     /** Link to first page, plus ellipses if necessary */
  1166.     if ( ! in_array( 1, $links ) ) {
  1167.         $class = 1 == $paged ? ' class="active"' : '';
  1168.  
  1169.         printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
  1170.  
  1171.         if ( ! in_array( 2, $links ) )
  1172.             echo '<li>…</li>';
  1173.     }
  1174.  
  1175.     /** Link to current page, plus 2 pages in either direction if necessary */
  1176.     sort( $links );
  1177.     foreach ( (array) $links as $link ) {
  1178.         $class = $paged == $link ? ' class="active"' : '';
  1179.         printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
  1180.     }
  1181.  
  1182.     /** Link to last page, plus ellipses if necessary */
  1183.     if ( ! in_array( $max, $links ) ) {
  1184.         if ( ! in_array( $max - 1, $links ) )
  1185.             echo '<li>…</li>' . "\n";
  1186.  
  1187.         $class = $paged == $max ? ' class="active"' : '';
  1188.         printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
  1189.     }
  1190.  
  1191.     /** Next Post Link */
  1192.     if ( get_next_posts_link() )
  1193.         printf( '<li%s><a href="%s"><i class="fa fa-angle-right"></i></a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
  1194.  
  1195.     echo '</ul></div>' . "\n";
  1196.  
  1197. }
  1198.  
  1199.  
  1200.  
  1201.    
  1202.    
  1203. /* Use this code and post in loop.php */
  1204.  
  1205.     <?php if (function_exists("pagination")) {
  1206.         pagination($additional_loop->max_num_pages);
  1207.     }
  1208.     ?>
  1209.  
  1210.  
  1211. =========================================================
  1212.             // shortcode এর জন্য code
  1213. =========================================================
  1214.  
  1215. // without attribute
  1216. ---------------------------------------------------------
  1217. function vimeo_shortcode( $atts, $content = null  ) {
  1218.     return '<iframe src="//player.vimeo.com/video/'.$content.'" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
  1219. }  
  1220. add_shortcode('vimeo', 'vimeo_shortcode');
  1221.  
  1222. // with attribute
  1223. ---------------------------------------------------------
  1224.  
  1225. function vimeo_video_shortcode( $atts, $content = null ) {
  1226.     $a = shortcode_atts( array(
  1227.         'id' => '74715441'
  1228.     ), $atts );
  1229.    
  1230.     return'<div class="res_video"><iframe src="http://player.vimeo.com/video/' . esc_attr($a['id']) . '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>';
  1231. }
  1232. add_shortcode('vimeo', 'vimeo_video_shortcode');
  1233.  
  1234. //widget এর text এ shoortcode support করানোর জন্য functions.php তে এই code টি কল করতে হবে
  1235. --------------------------------------------------------
  1236. add_filter('widget_text', 'do_shortcode');
  1237. //widget এর text এ PHP code support করানোর জন্য functions.php তে এই code টি কল করতে হবে
  1238. --------------------------------------------------------
  1239. add_filter('widget_text','execute_php',100);
  1240. function execute_php($html){
  1241.      if(strpos($html,"<"."?php")!==false){
  1242.           ob_start();
  1243.           eval("?".">".$html);
  1244.           $html=ob_get_contents();
  1245.           ob_end_clean();
  1246.      }
  1247.      return $html;
  1248. }
  1249.  
  1250. // do-shortcode এর জন্য code টি দিয়ে আপনার নির্দিষ্ট স্থানে paste করুন
  1251. --------------------------------------------------------
  1252. <?php echo do_shortcode('[your_desired_shortcode]'); ?>
  1253.  
  1254.         //custom_post in shortcode এর shortcode
  1255. --------------------------------------------------------
  1256. function category_post_shortcode($atts){
  1257.     extract( shortcode_atts( array(
  1258.         'title' => '',
  1259.         'link' => '',
  1260.         'category' => '',
  1261.     ), $atts, 'category_post' ) );
  1262.    
  1263.     $q = new WP_Query(
  1264.         array( 'category' => $category, 'posts_per_page' => '3', 'post_type' => 'post')
  1265.         );
  1266. $list = '<div class="latest_from_category"><h2 class="latest_frm_cat_title">'.$title.'</h2> <a href="'.$link.'" class="latest_more_link">more</a>';
  1267.  
  1268. while($q->have_posts()) : $q->the_post();
  1269.     //get the ID of your post in the loop
  1270.     $id = get_the_ID();
  1271.     $post_sub = get_post_meta($id, 'post_sub', true);  
  1272.     $post_thumbnail= get_the_post_thumbnail( $post->ID, 'post-thumbnail' );        
  1273.     $list .= '
  1274.    
  1275.                         <div class="single_cate_post floatleft">
  1276.                             '.$post_thumbnail.'
  1277.                             <h3>'.get_the_title().'</h3>
  1278.                             <p>'.$post_sub.'</p>
  1279.                             <a href="'.get_permalink().'" class="readmore">Read More</a>
  1280.                         </div>     
  1281.     ';        
  1282. endwhile;
  1283. $list.= '</div>';
  1284. wp_reset_query();
  1285. return $list;
  1286. }
  1287. add_shortcode('category_post', 'category_post_shortcode'); 
  1288.  
  1289. //custom_post shortcode এর list এ  html code এর ভিতর <?php the_title?>এবং <?php the_content?> পরিবর্তে হবে --------------------------------------------------------
  1290. '.get_the_title().' or ' .do_shortcode( get_the_title() ). '
  1291. '.get_the_content().'  
  1292. '.get_the_permalink().'
  1293. ' .get_the_excerpt(). '
  1294. '.get_the_date().'
  1295. '.get_the_author().'
  1296. '. get_site_url() .'
  1297. '.get_the_time( 'd/m/y', $post->ID).'
  1298.  
  1299. //for featured image
  1300. $featured_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'case-study-image' );
  1301. <img src="'.$featured_image_url[0].'" alt="" />
  1302.         or
  1303. $post_thumbnail= get_the_post_thumbnail( $post->ID, 'portfolio-thumbnail' );
  1304.         '.$post_thumbnail.'
  1305. //for Template directory uri
  1306. $theme_dir = get_bloginfo('template_directory');
  1307. <img src="'.$theme_dir.'/img/link_style.png" alt="" />
  1308.  
  1309. //for get metabox display
  1310. $idd = get_the_ID();
  1311. $animal_sub = get_post_meta($idd, 'animal_sub', true);
  1312.  -- display by this --
  1313. <p>'.$animal_sub.'</p>
  1314.  
  1315. //for Texonomy name
  1316.  $item_cats = get_the_terms($post->ID, 'slider_cat');
  1317.   if($item_cats):
  1318.   foreach($item_cats as $item_cat) {
  1319.    $item_classes = $item_cat->name ;
  1320.   }
  1321.   endif;
  1322.  
  1323.   -- display by this --
  1324.   <p>'.$item_classes.'</p>
  1325.  
  1326.  
  1327. ========================================================
  1328.                 //For 404 page
  1329. ========================================================
  1330. <!-- copy and past in 404.php -->
  1331. <div class="not_found">
  1332.     <h1>404 not found!</h1>
  1333.     <p>Sorry, but the page you are trying to reach is unavailable or does not exist.</p>
  1334.     <a id="submit" href="<?php bloginfo( 'home' ); ?>">Home</a>
  1335. </div>
  1336.  
  1337.  
  1338. ========================================================
  1339.                 //Reply Comment Scripts
  1340. ========================================================
  1341.  
  1342. <!-- copy and past in functions.php -->
  1343. function comment_scripts(){
  1344.  
  1345.    if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
  1346.  
  1347. }
  1348.  
  1349. add_action( 'wp_enqueue_scripts', 'comment_scripts' );
  1350.  
  1351.  
  1352. <!-- copy and past in comments.css From E/All source/comments.css -->
  1353.  
  1354.  
  1355. for
  1356.  
  1357.  
  1358. ==================================================
  1359.                 Wordpress এ  SMOF
  1360. ==================================================             
  1361.                 SMOF এর section array
  1362. --------------------------------------------------
  1363. $of_options[] = array(  "name"      => "General Settings",
  1364.                         "type"      => "heading"
  1365.                 );
  1366.  
  1367.                Wordpress এ SMOF এর array
  1368. --------------------------------------------------
  1369. $of_options[] = array(  "name"      => "Phone number",
  1370.                         "desc"      => "your phone number here",
  1371.                         "id"        => "phone_number",
  1372.                         // Use the shortcodes [site_url] or [site_url_secure] for setting default URLs
  1373.                         "std"       => "0535 954 74 54",
  1374.                         "type"      => "text"
  1375.                 );
  1376.  
  1377. SMOF এর option active code এটা target.php তে নির্দিষ্ট স্থানে paste হবে
  1378. --------------------------------------------------
  1379. <?php echo do_shortcode(stripslashes($data['phone_number'])); ?>   
  1380.  
  1381.  
  1382.  
  1383.            
  1384. ==========================================================
  1385.                     //Option Tree
  1386. ==========================================================
  1387. প্রথমে wordpress.org থেকে option tree download করুন
  1388. Download Option Tree: http://wordpress.org/extend/plugins/option-tree/
  1389. ডাউনলোড করার পর আপনার থিমে option-tree folder টি রেখে দিবেন
  1390. option-tree folderএর মধ্যে থাকা ot-loader.php টি function এ include করতে হবে
  1391. function এ  গিয়ে প্রথমে
  1392.  
  1393. //Activate Option Tree just copy & paste this code in functions.php
  1394.  
  1395. //add_filter( 'ot_show_pages', '__return_false' ); কাজ শেষে এই লাইনটির কমেন্ট উঠিয়ে দিতে হবে
  1396. add_filter( 'ot_show_new_layout', '__return_false' );
  1397. add_filter( 'ot_theme_mode', '__return_true' );
  1398. include_once( 'option-tree/ot-loader.php' );
  1399. include_once( 'inc/theme-options.php' );
  1400. include_once( 'inc/meta-boxes.php' );
  1401.  
  1402. Meta-box build-up করার জন্য প্রথমে assets > theme-mode > demo-meta-boxes.php ফাইলটি কপি করুন তারপর আপনার থিমের মধ্যে একটা ফোল্ডার করবেন নাম দিবেন inc এবার এই folder এর ভিতর ফাইলটি pasteকরুন এবার ফাইলটির নাম পরিবর্তন করে শুধু meta-boxes.php নাম দিন। এবার functons.php তে গিয়ে ফাইলটি চিনিয়ে দিবেন include_once('inc/meta-boxes.php'); এই লাইনটি লিখে দিবেন। এবার  meta-boxes.php ফাইলটি ওপেন করুন
  1403.  
  1404. function custom_meta_boxes() {
  1405.  
  1406.   /*
  1407.    * Create a custom meta boxes array that we pass to
  1408.    * the OptionTree Meta Box API Class.
  1409.    */
  1410.   $my_meta_box/*আপনার meta_box যেকোনো নাম */ = array(
  1411.     'id'          => 'demo_meta_box',/* আপনার meta_box নাম এবং id একই হইতে পারে */
  1412.     'title'       => __( 'Demo Meta Box', 'theme-text-domain' ),/* আপনার meta_box এর titl */
  1413.     'desc'        => '',/* আপনার meta_box এর দিকনির্দেশনা */
  1414.     'pages'       => array( 'post' ),/* আপনার post-type এর নাম */
  1415.     'context'     => 'normal',
  1416.     'priority'    => 'high',
  1417.     'fields'      => array(
  1418.       array(
  1419.         'label'       => __( 'Conditions', 'theme-text-domain' ),/* আপনার meta_box এর option এর label বা নাম  */
  1420.         'id'          => 'demo_conditions', /* আপনার custom-field id নাম */
  1421.         'desc'          => '', /* আপনার meta_box এর option এর দিকনির্দেশনা */
  1422.         'type'        => 'tab',/* আপনার meta_box এর option এর type */
  1423.         'std'         => 'off',/* আপনার meta_box এর option এর default data যেটা দেখতে চান */
  1424.         'operator'    => 'and',
  1425.         'condition'   => 'demo_show_gallery:is(on),demo_gallery:not()'
  1426.       ),
  1427.      
  1428.     )
  1429.   );
  1430.  
  1431.   /**
  1432.    * Register our meta boxes using the
  1433.    * ot_register_meta_box() function.
  1434.    */
  1435.   if ( function_exists( 'ot_register_meta_box' ) )
  1436.     ot_register_meta_box( $my_meta_box );/* সবশেষে আপনার meta_box নাম দিয়ে শেষ করতে হবে*/
  1437.  
  1438. }
  1439.  
  1440. this code is for specific page metabox
  1441. --------------------------------------------
  1442. $price_page_meta_box = array(
  1443.     'id'          => 'price_page_meta_box',
  1444.     'title'       => 'Pricing Page Table Information',
  1445.     'desc'        => '',
  1446.     'pages'       => array( 'page' ),
  1447.     'context'     => 'normal',
  1448.     'priority'    => 'high',
  1449.     'fields'      => array(
  1450.       array(
  1451.         'label'       => 'Pricing Page Table Head',
  1452.         'id'          => 'pric_table_head',
  1453.         'std'          => '',
  1454.         'type'        => 'textarea'
  1455.       ),
  1456.     )
  1457.   );
  1458.  
  1459.   $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];
  1460. $template_file = get_post_meta($post_id, '_wp_page_template', TRUE);
  1461.  
  1462. if ($template_file == 'price-newmeta.php') {
  1463.     ot_register_meta_box( $price_page_meta_box );
  1464. }
  1465.  
  1466.  
  1467. এবার dashboard গিয়ে দেখবেন custom-field এর স্থলে আলাদাভাবে  meta-boxes চলে এসেছে
  1468.  
  1469. //option tree থেকে শুধুমাত্র  metabox use করতে নিচের code লেখুন functions.php
  1470. add_filter( 'ot_show_pages', '__return_false' );
  1471. add_filter( 'ot_use_theme_options', '__return_false' );
  1472.     ====/   or  /====
  1473. function remove_ot_menu () {
  1474.     remove_submenu_page( 'themes.php', 'ot-theme-options' );
  1475. }
  1476. add_action( 'admin_init', 'remove_ot_menu' );
  1477.  
  1478.  
  1479. option build-up করার জন্য প্রথমে assets > theme-mode > demo-theme-options.php ফাইলটি কপি করুন তারপর আপনার থিমের মধ্যে একটা ফোল্ডার করবেন নাম দিবেন inc এবার এই folder এর ভিতর ফাইলটি pasteকরুন এবার ফাইলটির নাম পরিবর্তন করে শুধু theme-options.php নাম দিন। এবার functons.php তে গিয়ে ফাইলটি চিনিয়ে দিবেন include_once(meta'inc/theme-options.php'); এই লাইনটি লিখে দিবেন। এবার dashboard > appearance গিয়ে দেখবেন theme option চলে এসেছে
  1480.  
  1481. এবার theme-options.php ফাইলটির ভিতরের যেই sections এবং settings গুলি দরকার নেই সেইগুলি কেটে দিব।   settings এর ভিতর যতগুলি array নিবেন ততগুলি option তৈরি হবে  প্রত্যেকটি sections এর under এ।sections গুলু আপনার ইচ্ছামত যেইকয়টা লাগবে সেই কয়টা নিতে পারবেন এবং নাম দিতে পারবেন। এ। sections এর array তেtitle & id নিলেই হবে আর কিছু লাগবেনা
  1482.  
  1483.         //Create Option Tree In the theme-options.php
  1484. -----------------------------------------------------------
  1485.  
  1486.     <?php
  1487.         add_action( 'admin_init', 'custom_theme_options', 1 );
  1488.         function custom_theme_options() {
  1489.             $saved_settings = get_option( 'option_tree_settings', array() );
  1490.             $custom_settings = array(
  1491.                 'sections' => array(
  1492.                 array(
  1493.                 'id' => 'general',
  1494.                 'title' => 'Site Settings'
  1495.                 )
  1496.                 ),
  1497.                 'settings' => array(
  1498.                 array(
  1499.                 'id' => 'logo_text',
  1500.                 'label' => 'Logo Text',
  1501.                 'desc' => 'Use H1, H2, H3 tag',
  1502.                 'type' => 'textarea',
  1503.                 'section' => 'general'
  1504.                 ),
  1505.                 array(
  1506.                 'id' => 'footer_text',
  1507.                 'label' => 'Footer Text',
  1508.                 'type' => 'textarea',
  1509.                 'section' => 'general'
  1510.                 )
  1511.                 )
  1512.                 );
  1513.                 if ( $saved_settings !== $custom_settings ) {
  1514.                 update_option( 'option_tree_settings', $custom_settings );
  1515.                 }
  1516.         }
  1517.     ?>
  1518.  
  1519.         //Get Data From Option Tree
  1520. ------------------------------------------------------
  1521.         //Condtional Data
  1522. <?php if ( function_exists( 'get_option_tree') ) : if( get_option_tree( 'your_tree_id') ) : ?>
  1523. <?php get_option_tree( 'your_tree_id', '', true ); ?>
  1524. <?php else : ?>
  1525. Your Default Data here
  1526. <?php endif; endif; ?>
  1527.  
  1528. == example ==
  1529. <?php if ( function_exists( 'get_option_tree') ) : if( get_option_tree( 'header-logo') ) : ?>
  1530. <img src="<?php get_option_tree( 'header-logo', '', true ); ?>" alt="" />
  1531. <?php else : ?>
  1532. <img src="<?php echo get_template_directory_uri(); ?>/img/logo.png" alt="" />
  1533. <?php endif; endif; ?>
  1534.  
  1535. ---------or----------------
  1536. <?php
  1537. $facebook = get_option_tree('facebook-link', '', false);
  1538. ?>
  1539. <?php echo $facebook; ?>
  1540.  
  1541. ---------or----------------
  1542. <?php get_option_tree( 'logo_link1', '', true ); ?>
  1543.  
  1544.         //Get Data From Option Tree Metabox
  1545. ------------------------------------------------------
  1546. <?php
  1547. $case_sub = get_post_meta($post->ID, 'case_sub', true);
  1548. ?>
  1549. <?php echo $case_sub; ?>
  1550.  
  1551. ---------or----------------
  1552. <?php echo get_post_meta($post->ID, 'case_sub', true); ?>
  1553.    
  1554. // this code for css style dynamic by theme option and metabox
  1555.    
  1556. <style type="text/css">
  1557.     .logo {background: url(<?php get_option_tree( 'logo', '', 'true' ); ?>) no-repeat center center;}
  1558.     .prcbanner_content h1{color:<?php echo get_post_meta($post->ID, 'picker', true); ?>}
  1559. </style>
  1560.  
  1561. /*for option tree  metabox short code support */
  1562. <?php
  1563. $mixitup = get_post_meta($post->ID, 'mixitup', true);
  1564. ?>
  1565.  
  1566. <?php echo do_shortcode($mixitup); ?>
  1567.  
  1568. ======================================================
  1569.  How to get cropped / resized images through option tree meta box
  1570.  metabox image resize code
  1571. ======================================================
  1572.  
  1573. // register your gallery type meta box and use the following code to display images.
  1574. <?php
  1575.     if ( function_exists( 'ot_get_option' ) ) {
  1576.        $images = explode( ',', get_post_meta( get_the_ID(), 'field-id', true ) );
  1577.       if ( !empty( $images ) ) {
  1578.         foreach( $images as $id ) {
  1579.           if ( !empty( $id ) ) {
  1580.             $full_img_src = wp_get_attachment_image_src( $id, 'your_crop_image' );
  1581.             echo '<li><img src="' . $full_img_src[0]. '"/></li>';
  1582.           }
  1583.         }
  1584.       }
  1585.     }
  1586. ?>
  1587. In line no 4 the field-id is your meta box id.You can define as much as image sizes you want with your-image-size which you can see in the line no 08 & 09 . The your-image-size is your image id which you created by add_image_size() function in the functions.php .Thank You!
  1588.  
  1589. //------------------ another way maybe works not tested ------------------------------
  1590.     $burst_img = get_post_meta( $post->ID, 'burst_img',true);              
  1591.     $burst_img=wp_get_attachment_image_src( $burst_img, 'full' );
  1592.    
  1593.    
  1594. //option tree image resize code
  1595. paste this code into functions.php
  1596. ----------------------------------
  1597. function custom_get_attachment_id( $guid ) {
  1598.   global $wpdb;
  1599.  
  1600.   /* nothing to find return false */
  1601.   if ( ! $guid )
  1602.     return false;
  1603.  
  1604.   /* get the ID */
  1605.   $id = $wpdb->get_var( $wpdb->prepare(
  1606.     "
  1607.     SELECT  p.ID
  1608.     FROM    $wpdb->posts p
  1609.     WHERE   p.guid = %s
  1610.             AND p.post_type = %s
  1611.     ",
  1612.     $guid,
  1613.     'attachment'
  1614.   ) );
  1615.  
  1616.   /* the ID was not found, try getting it the expensive WordPress way */
  1617.   if ( $id == 0 )
  1618.     $id = url_to_postid( $guid );
  1619.  
  1620.   return $id;
  1621. }
  1622.  
  1623. paste this code where you want to display
  1624. -------------------------------------
  1625. $slides = ot_get_option( 'my_slider', array() );
  1626. if ( ! empty( $slides ) ) {
  1627.     foreach( $slides as $slide ) {
  1628.         $id = custom_get_attachment_id( $slide['image'] );
  1629.         $src = wp_get_attachment_image_src( $id, 'you-image-size' );
  1630.         echo 'HTML HERE';
  1631.     }
  1632. }
  1633.  
  1634. ---------------- // or try this ----------------------------
  1635.  
  1636.     if ( function_exists( 'ot_get_option' ) ) {
  1637.         $images = explode( ',', ot_get_option( 'field_id', '' ) );
  1638.             if ( ! empty( $images ) ) {
  1639.             foreach( $images as $id ) {
  1640.             if ( ! empty( $id ) ) {
  1641.             $full_img_src = wp_get_attachment_image_src( $id, 'your_crop_image' );
  1642.  
  1643.             echo '<li><img src="' . $full_img_src[0]. '"/></li>';
  1644.            
  1645.                 }      
  1646.             }
  1647.         }
  1648.     }
  1649. //------------------ another way maybe works not tested ------------------------------
  1650.    
  1651.     $burst_img = ot_get_option('burst_img','');                
  1652.     $burst_img=wp_get_attachment_image_src( $burst_img, 'full' );
  1653.  
  1654. =======================================================
  1655. metabox category-select type query code
  1656. =======================================================
  1657. <?php
  1658. $cat = ot_get_option( 'your_id', '', false, true, 0 );
  1659. $args = array( 'numberposts' =>1, 'category'=> $cat);
  1660. $postslist = get_posts( $args );
  1661. foreach ($postslist as $post) :  setup_postdata($post);
  1662. ?>
  1663.  
  1664. <?php the_title(); ?>
  1665. <?php the_content(); ?>
  1666.  
  1667. <?php endforeach; ?>
  1668.  
  1669. =======================================================
  1670. metabox slide type query code fpr owl slider
  1671. =======================================================
  1672.  
  1673. //this code paste in metabox.php file
  1674. array(
  1675.     'id'          => 'spyr_demo_slider',
  1676.     'label'       => __( 'Slider', 'text-domain' ),
  1677.     'desc'        => __( 'Your description', 'text-domain' ),
  1678.     'type'        => 'slider',
  1679. )
  1680.  
  1681. //this code paste in template.php file
  1682. <?php
  1683. $spyr_demo_slider = get_post_meta( $post->ID, 'spyr_demo_slider', true );
  1684.  
  1685. // Loop through the array to build your Slider.
  1686. // Note that every slider is different
  1687. // We have access to the following array keys
  1688. // title, description, image and link
  1689. echo '<div id="owl-demo" class="owl-theme">';
  1690. foreach( $spyr_demo_slider as $slide ) {
  1691.     echo '<div class="item"><img src="'. $slide['image'] .'" width="100%" height="auto"
  1692.          alt="'. $slide['description'] .'" title="'. $slide['title'] .'" /></div>';
  1693. }
  1694. echo '</div>';
  1695.  
  1696. ?>
  1697.  
  1698. =======================================================
  1699. metabox list type query code
  1700. =======================================================
  1701. <?php
  1702.  
  1703. $list_item = ot_get_option( 'id', array() );
  1704.  
  1705. if ( !empty( $list_item ) ) {
  1706.  
  1707. echo '<div>';
  1708.  
  1709. foreach( $list_item as $name ) {
  1710.  
  1711. echo '<div>'.$name['title'].'</div>
  1712.  
  1713. ';
  1714.  
  1715. }
  1716.  
  1717. echo '</div>';
  1718.  
  1719. }
  1720.  
  1721. ?>
  1722.  
  1723. ------------------------------------------------------ 
  1724.         //Simple Data
  1725. <?php get_option_tree( 'facebook', '', true ); ?>
  1726.  
  1727. নিচের কোডগুলু দিয়েও করা যায় । অনেকগুলু option দরকার হইলে আমরা variable নিয়ে করব যাতে করে আমরা echo করে নিয়ে নিতে পারি । আমরা যখন condition ব্যাবহার করবো তখন variable নেওয়া লাগে।
  1728. <?php $your_variable = get_option_tree( 'your_tree_id', '', false ); ?>
  1729. <?php echo $your_variable; ?> এই কোডটি যেখানে দরকার সেখানে paste করব
  1730. -------------------------------------------------------------
  1731. প্রথমে variable নিতে হবে নোটঃ একাধিক option দরকার হইলে একাধিক variable নিবেন  <?php এখানে হবে ?>
  1732. যেমনঃ
  1733. <?php $your_variable = get_option_tree( 'your_tree_id', '', false )
  1734.       $your_variable = get_option_tree( 'your_tree_id', '', false );
  1735. ?>
  1736. তারপর নিচে নিচে condition হবে প্রত্যেকটার জন্য আলাদা আলাদা করে condition নিবেন
  1737. যেমনঃ
  1738. <?php if(your_variable) : ?>
  1739.     <?php echo $your_variable; ?>
  1740. <?php else : ?>
  1741.     your fallback data
  1742. <?php endif; ?>
  1743.  
  1744. <?php if(your_variable) : ?>
  1745.     <?php echo $your_variable; ?>
  1746. <?php else : ?>
  1747.     your fallback data
  1748. <?php endif; ?>
  1749.  
  1750. // slider না দেখতে চাইলে নিচের কোডগুলি দিয়ে করতে পারেন
  1751. <?php
  1752. $slider_appearance = get_option_tree( 'slider_appearance', '', false );
  1753. ?>
  1754.  
  1755. <?php if($slider_appearance = 'no') : ?>
  1756. <?php /* No Data */?>
  1757. <?php if($slider_appearance = 'yes') : ?>
  1758. <?php get_template_part('slider'); ?>
  1759. <?php endif; endif; ?>
  1760.  
  1761. ============================================================
  1762. // REMOVE BAD P and BR TAGS FROM NAME ANCHORS
  1763. ============================================================
  1764. add_filter('the_content', 'remove_bad_pbr_tags');
  1765. function remove_bad_pbr_tags($content) {
  1766.         $pattern = '/<p><a name=[\"\'](.*)[\"\']><br\s*\/>\s*<h([1-9])>(.*)<\/h([1-9])>\s*<p><\/a><br\s*\/>/';
  1767.         $replacement = "<a name=\"$1\"><h$2>$3</h$4></a>\n<p>";
  1768.     $content = preg_replace($pattern, $replacement, $content);
  1769.     return $content;
  1770. }
  1771. -------------------------------------------------------------
  1772.                         or
  1773. -------------------------------------------------------------
  1774. // REMOVE BAD P and BR TAGS FROM NAME ANCHORS
  1775. remove_filter( 'the_content', 'wpautop' );
  1776. remove_filter( 'the_excerpt', 'wpautop' );
  1777.  
  1778. function wpse_wpautop_nobr( $content ) {
  1779.     return wpautop( $content, false );
  1780. }
  1781.  
  1782. add_filter( 'the_content', 'wpse_wpautop_nobr' );
  1783. add_filter( 'the_excerpt', 'wpse_wpautop_nobr' );
  1784.  
  1785. =============================================================
  1786. In qTranslate-x Change logo/image based on language selected
  1787. =============================================================
  1788.     <?php  
  1789.     if ( qtranxf_getLanguage() == 'pt' ) {
  1790.       echo '<img src="http://www.cunhapontes.adv.br/wp-content/themes/cunhapontes/img/locatcontato.png" alt="" />';
  1791.     }
  1792.     elseif ( qtranxf_getLanguage() == 'es' ) {
  1793.      echo '<img src="http://www.cunhapontes.adv.br/wp-content/themes/cunhapontes/img/location_es.png" alt="" />';
  1794.     }
  1795.     elseif ( qtranxf_getLanguage() == 'en' ) {
  1796.      echo '<img src="http://www.cunhapontes.adv.br/wp-content/themes/cunhapontes/img/location_eng.png" alt="" />';
  1797.     }
  1798.   ?>
  1799.  
  1800. =============================================================
  1801. <?                  //Post View Count
  1802. =============================================================
  1803.         //আপনার functions.php তে এই কোডটি যুক্ত করুন
  1804. -------------------------------------------------------------
  1805.             // function to display number of posts.
  1806. getPostViews($postID){ $count_key = 'post_views_count'; $count = get_post_meta($postID,
  1807. $count_key, true); if($count==''){ delete_post_meta($postID, $count_key);
  1808. add_post_meta($postID, $count_key, '0'); return "0 View"; } return $count.' Times';}
  1809.  
  1810.             // function to count views.
  1811. function setPostViews($postID) { $count_key = 'post_views_count';
  1812. $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0;
  1813. delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{
  1814. $count++; update_post_meta($postID, $count_key, $count); }}
  1815.  
  1816. আপনি যেখানে পোস্ট ভিউ কাউন্ট সেট করতে চান সেখানকার  লুপে এই কোডের পরে এই কোডটি যুক্ত করুন আপনি যেখানে পোস্ট ভিউ কাউন্ট দেখাতে চান
  1817.  
  1818.  
  1819. =============================================================
  1820.             //Post View timer Count
  1821. =============================================================
  1822. <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>
  1823.  
  1824. =============================================================
  1825.                     //Bangla date view
  1826. =============================================================
  1827.         //আপনার functions.php তে এই কোডটি যুক্ত করুন
  1828. -------------------------------------------------------------
  1829. function bn($mhm)
  1830. {
  1831.     $eng = array('January','February','March','April','May','June','July','August','September','October','November','December',
  1832.                  'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec',
  1833.                  'Saturday','Sunday','Monday','Tuesday','Wednesday','Thursday','Friday',
  1834.                  'Sat','Sun','Mon','Tue','Wed','Thu','Fri',
  1835.                  '1','2','3','4','5','6','7','8','9','0',
  1836.                  'am','pm','st','nd','rd','th');
  1837.     $bng = array('জানুয়ারি','ফেব্রুয়ারি','মার্চ','এপ্রিল','মে','জুন','জুলাই','আগস্ট','সেপ্টেম্বর','অক্টোবর','নভেম্বর','ডিসেম্বর',
  1838.                  'জানু','ফেব্রু','মার্চ','এপ্রি','মে','জুন','জুলা','আগ','সেপ্টে','অক্টো','নভে','ডিসে',
  1839.                  'শনিবার','রবিবার','সোমবার','মঙ্গলবার','বুধবার','বৃহস্পতিবার','শুক্রবার',
  1840.                  'শনি','রবি','সোম','মঙ্গল','বুধ','বৃহঃ','শুক্র',
  1841.                  '১','২','৩','৪','৫','৬','৭','৮','৯','০',
  1842.                  'পূর্বাহ্ণ','অপরাহ্ণ','&#173;','&#173;','&#173;','&#173;');
  1843.     $con = str_replace($eng, $bng, $mhm);
  1844.     return $con;
  1845. }
  1846. add_action('wp_head', function() {
  1847. echo '<meta name="mhm" content="bdat 1.3" />';});
  1848. add_filter('the_date', 'bn');
  1849. add_filter('the_time', 'bn');
  1850. add_filter('the_views', 'bn');
  1851. add_filter('comments_number', 'bn');
  1852. add_filter('get_comment_date', 'bn');
  1853. add_filter('get_comment_time', 'bn');
  1854.  
  1855. ============================================================
  1856. How to add custom header and custom background in wordpress theme
  1857. ============================================================
  1858.  
  1859.         //Title: custom background.
  1860. ------------------------------------------------------------
  1861.         head.php
  1862. ..............
  1863. replace the
  1864. tag using bellow the code.
  1865. >
  1866.  
  1867. functions.php
  1868. .........................
  1869. this code put within the tag
  1870.  
  1871. $defaults = array(
  1872. 'default-color' => '#000',
  1873. 'default-image' => '',
  1874. 'wp-head-callback' => '_custom_background_cb',
  1875. 'admin-head-callback' => '',
  1876. 'admin-preview-callback' => ''
  1877. );
  1878. add_theme_support( 'custom-background', $defaults );
  1879.  
  1880.  
  1881. Title: custom Header/Logo
  1882. ---------------------------------------------
  1883.  
  1884. head.php
  1885. ..........................
  1886. Put this code where you want to upload your logo.
  1887. ----------------------------------------------
  1888.  
  1889. functions.php
  1890. ..........................
  1891. this code put within the tag
  1892.  
  1893. $defaults = array(
  1894. 'default-image' => '',
  1895. 'random-default' => true,
  1896. 'width' => 1000,
  1897. 'height' => 200,
  1898. 'flex-height' => true,
  1899. 'flex-width' => true,
  1900. 'default-text-color' => '#000',
  1901. 'header-text' => true,
  1902. 'uploads' => true,
  1903. 'wp-head-callback' => '',
  1904. 'admin-head-callback' => '',
  1905. 'admin-preview-callback' => '',
  1906. );
  1907. add_theme_support( 'custom-header', $defaults );
  1908.  
  1909.  
  1910. ===============================================
  1911. social share code for wordpress
  1912. ===============================================
  1913.  
  1914. -------------------------------------
  1915. <div class="social">
  1916.         <p>সবার সাথে শেয়ার করুন:</p>
  1917.         <!--Twitter-->
  1918.         <a class="twitter" href="http://twitter.com/home?status=<?php the_title(); ?>: <?php the_permalink(); ?>" target="_blank"><i class="fa fa-twitter"></i> </a>
  1919.         <!--Facebook-->
  1920.         <a class="facebook" href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&amp;t=<?php the_title(); ?>" title="Share this post on Facebook!" onclick="window.open(this.href); return false;"><i class="fa fa-facebook"></i> </a>
  1921.         <!--Google Plus-->
  1922.         <a class="google-plus" target="_blank" href="https://plus.google.com/share?url=<?php the_permalink(); ?>"><i class="fa fa-google-plus"></i> </a>
  1923.         <a class="reddit" href="http://www.reddit.com/submit?url=<?php the_permalink(); ?>&amp;title=<?php the_title(); ?>" title="Reddit" rel="nofollow" target="_blank"><i class="fa fa-reddit"></i> </a>
  1924.         <a class="stumbleupon" href="http://www.stumbleupon.com/submit?url=<?php the_permalink(); ?>&amp;title=<?php the_title(); ?>" title="Stumble it" rel="nofollow" target="_blank"><i class="fa fa-stumbleupon"></i> </a>
  1925.         <!--Digg-->
  1926.         <a class="digg" href="http://digg.com/submit?url=<?php the_permalink(); ?>&amp;title=<?php the_title(); ?>" title="Digg this!" rel="nofollow" target="_blank"><i class="fa fa-digg"></i></a>
  1927.         <!--Linkedin-->
  1928.         <a class="linkedin" href="http://www.linkedin.com/shareArticle?mini=true&amp;title=<?php the_title(); ?>&amp;url=<?php the_permalink(); ?>" title="Share on LinkedIn" rel="external nofollow" rel="nofollow" target="_blank"><i class="fa fa-linkedin"></i></a>
  1929.         <!--Pinterest-->
  1930.         <a class="pinterest" href="http://pinterest.com/pin/create/button/?url=<?php the_permalink(); ?>&media=<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); echo $url; ?>" title="Pinterest" rel="nofollow" target="_blank"><i class="fa fa-pinterest"></i></a>
  1931.         <!--Del.icio.us-->
  1932.         <a class="delicious" href="http://del.icio.us/post?url=<?php the_permalink(); ?>&amp;title=<?php the_title(); ?>" title="Bookmark on del.icio.us" rel="nofollow" target="_blank"><i class="fa fa-delicious"></i></a>
  1933. </div>
  1934.  
  1935.  
  1936.  
  1937.  ফেসুবকের বিভিন্ন লাইক বাটন যোগ করতে এখানে দেখতে পারেন
  1938.  ---------------------------------------------
  1939.  https://developers.facebook.com/docs/plugins/like-button/
  1940. ============================================
  1941.  /*Add Submenu in sidebar on wordpress*/
  1942. =============================================
  1943. /*Firstly, in your theme's functions.php, you need to write a function to register the names of your menus.*/
  1944.  
  1945.   function register_my_menus() {
  1946.   register_nav_menus(
  1947.     array( 'sidebar-menu' => __( 'Sidebar Menu' ) )
  1948.   );
  1949. }
  1950. add_action( 'init', 'register_my_menus' );
  1951.  
  1952. /*Display Menus on Theme
  1953.  
  1954. Once you've done that, your theme will be almost ready. The last preparation step is to tell the theme where you want the menus to show up.*/
  1955.  
  1956. <?php wp_nav_menu( array( 'theme_location' => 'sidebar-menu' ) ); ?>
  1957.  
  1958. /*That's all the background work. To finish, you would simply visit the Appearance -> Menus panel in your site admin.
  1959.  
  1960. Please read the wordpress codex site.. it has plenty of information on how to do this..*/
  1961.  
  1962.  
  1963. ==============================================
  1964. How to Remove WordPress Admin Bar for All Users Except Admin
  1965. ==============================================
  1966. add_action('after_setup_theme', 'remove_admin_bar');
  1967.  
  1968. function remove_admin_bar() {
  1969.  
  1970. if (!current_user_can('administrator') && !is_admin()) {
  1971.  
  1972. show_admin_bar(false);
  1973.  
  1974. }
  1975.  
  1976. }
  1977. ------------------------
  1978. If you want to disable it for all users, then simply paste this blew code in your theme’s functions.php file
  1979. ----------------------------------------------
  1980. show_admin_bar(false);
  1981.  
  1982. ==============================================
  1983. আপনার ওয়ার্ডপ্রেস ড্যাশবোর্ডর ‘Howdy’ লেখাকে পরিবর্তন করে দিন ইচ্ছা মতো যেকোনো কিছু।
  1984. ==============================================
  1985. add_filter('gettext', 'change_howdy', 10, 3);
  1986. function change_howdy($translated, $text, $domain) {
  1987.  
  1988. if (false !== strpos($translated, 'Howdy'))
  1989. return str_replace('Howdy', 'স্বাগতম', $translated);
  1990.  
  1991. return $translated;
  1992. }
  1993.  
  1994. এখানে আপনি ‘স্বাগতম’ এর জাইগায় আপনার পছন্দ মতো যেকোনো শব্দ দিতে পারেন। আজ তবে এখানে।ভাল থাকবেন।
  1995.  
  1996. ==============================================
  1997. এখন থেকে কেউ লগ আউট করলে সরাসরি তাকে নিয়ে যাবে হোম পেজে
  1998. ==============================================
  1999. add_action('wp_logout','go_home');
  2000. function go_home(){
  2001. wp_redirect( home_url() );
  2002. exit();
  2003. }
  2004.  
  2005. ==============================================
  2006. নিয়ে নিন সুন্দর একটা বাংলা লগিন/রেজিস্টার প্যানেল
  2007. ==============================================
  2008. খুবই সহজ সুধু নিছের কোড কপি করে আপনার সাইট এর sidebar এর text widget এ past করে সেভ করুন ব্যাস কাজ শেষ।
  2009.  
  2010. <?php global $user_ID, $user_identity, $user_level ?>
  2011. <?php if ( $user_ID ) : ?>
  2012. <h2> স্বাগতম/Welcome <strong><?php echo $user_identity ?></strong></h2>
  2013. <li><a href="<?php bloginfo('url') ?>/wp-admin/">ড্যাশবোর্ডে/Dashboard</a></li>
  2014. <?php if ( $user_level >= 1 ) : ?>
  2015. <li><a href="<?php bloginfo(‘url’) ?>/wp-admin/post-new.php">নতুন পোষ্ট লিখুন।/New Post</a></li>
  2016. <?php endif // $user_level >= 1 ?>
  2017. <li><a href="<?php bloginfo('url') ?>/wp-admin/profile.php">আপনার প্রোফাইল পাতা/Profile</a></li>
  2018. <li><a href="<?php bloginfo('url') ?>/wp-login.php?action=logout&amp;redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']) ?>">বের হয়ে যান/Logout</a></li>
  2019. </ul>
  2020. </li>
  2021. </ul>
  2022. <?php elseif ( get_option('users_can_register') ) : ?>
  2023. <h2><p style="text-align: center;">মেম্বার লগিন প্যানেল/Login panel</p></h2>
  2024. <hr/>
  2025. <ul>
  2026. <form action="<?php bloginfo('url') ?>/wp-login.php" method="post">
  2027. <p>
  2028. <label for="log"><input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="25" /> <br/>ইউজার নেম দিন/Username</label><br /><br/>
  2029. <label for="pwd"><input type="password" name="pwd" id="pwd" size="25" /><br />
  2030. পাসওয়ার্ড দিন/Password</label><br/><br/>
  2031. <input type="submit" name="submit" value="লগিন/Login" />
  2032. <label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" />আমাকে মনে রাখুন/Remember Password</label><br />
  2033. </p>
  2034. <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/>
  2035. </form>
  2036. </li>
  2037.  
  2038. <hr/>
  2039.  
  2040. <a href="<?php bloginfo('url') ?>/wp-login.php?action=register">Registration/রেজিস্ট্রেশন</a>
  2041.  
  2042. <br/>
  2043.  
  2044. <a href="<?php bloginfo('url') ?>/wp-login.php?action=lostpassword">Reset Password/পাসওয়ার্ড পুনরুদ্ধার</a>
  2045. </ul>
  2046. <?php endif // get_option('users_can_register') ?>
  2047.  
  2048.  
  2049.  
  2050.  
  2051. ==============================================
  2052. আপনার ওয়ার্ডপ্রেস ড্যাশবোর্ড প্যানেল থেকে theme editor lock করে দিন কোড দিয়ে
  2053. ==============================================
  2054. add_action('admin_init', 'cwc_lock_theme');
  2055. function cwc_lock_theme() {
  2056. global $submenu, $userdata;
  2057. get_currentuserinfo();
  2058. if ($userdata->ID != 1) {
  2059. unset($submenu['themes.php'][5]);
  2060. unset($submenu['themes.php'][15]);
  2061. }
  2062. }
  2063.  
  2064. ==============================================
  2065. আপনার ওয়ার্ডপ্রেস সাইট এ কোন শব্দ কে অন্য শব্দ দিয়ে পরিবর্তন করুন
  2066. ==============================================
  2067. হ্যালো, বন্ধুরা কেমন আছ। আবারো হাজির হলাম আপনাদের সামনে। আজকে ছোট একটা কোড নিয়ে আলোচনা করবো। আমরা যখন আমাদের ওয়ার্ডপ্রেস সাইট এ বাংলা ইন্সটল করি তখন অনেক শব্দের বাংলা অর্থ এমন যে শুনতে কেমন লাগে। যেমন Dashboard এর মানে দেখায় খেরখাতা। তাই আপনি চাইলে কিছু ওয়ার্ড এর মানে আপনি কোড দিয়ে Replace করতে পারেন। এর জন্য নিছের কোড গুলো আপনার থিমের functions.php ফাইলে অ্যাড করে দিন।
  2068.  
  2069. add_filter('gettext', 'rename_admin_menu_items');
  2070. add_filter('ngettext', 'rename_admin_menu_items');
  2071. function rename_admin_menu_items($menu) {
  2072. $menu = str_ireplace('Dashboard', 'প্রথম পাতা', $menu);
  2073. $menu = str_ireplace('Media', 'ছবিসমুহ', $menu);
  2074. $menu = str_ireplace('Comments', 'মন্তব্যসমুহ', $menu);
  2075. return $menu;
  2076. }
  2077. এখানে আমি কিছু উদাহরন দিলাম।
  2078. $menu = str_ireplace('Media', 'ছবিসমুহ', $menu);
  2079.  
  2080. উপরের লাইন এ খেয়াল করুন। এখানে মনে করেন আপনি Media কে পরিবর্তন করবেন এখন উপরের Media এর পরিবরতে যে শব্দ ব্যবহার করতে চান সেটি ছবিসমুহ এর জায়গায় বসিয়ে দিন দেখবেন আপনার সাইট যত Media লেখা আছে সব পরিবর্তন হয়ে গেছে। এভাবে আপনার যত খুশি শব্দ অ্যাড করতে পারেন। আমি শুধু কয়েকটি শব্দ দিয়েছি দেখানোর জন্য।
  2081.  
  2082.  
  2083.  
  2084. ==============================================
  2085. যেকোনো পোস্ট এ অ্যাড করুন লেখকের আভাটার
  2086. ==============================================
  2087. <?php echo get_avatar( get_the_author_email(), '20' ); ?>
  2088.  
  2089.  
  2090. ==============================================
  2091. আপনার ওয়েবসাইট এ ডিফল্ট Avatar পরিবর্তন করুন কোড দিয়ে
  2092. ==============================================
  2093. ওয়ার্ডপ্রেস সাইট এ ওয়ার্ডপ্রেস এর দেয়া অনেক গুলো ডিফল্ট Avatar থাকে। আমরা যারা ওয়ার্ডপ্রেস দিয়ে সাইট বানাই তাদের অনেক সময় Branding এর কারনে এই ডিফল্ট Avatar পরিবর্তন করতে হয়। অনেকে এটা plugin দিয়ে করে তবে জে কাজ সামান্য কোড দিয়ে হয় সেটার জন্য কেন plugin ব্যবহার করতে যাবো। কাজতা খুবই সজা । সুধু নিছের কোড টুকু কপি করে আপনার ওয়ার্ডপ্রেস সাইট এর theme এর functions.php file এর আকদম নিছে paste করে দিন। আর আপনার সাইট এর theme এর ইমেজ directory তে যে ইমেজটা ব্যবহার করতে চান সেটা rename করে avatar.png format এ নিয়ে upload করে দিন ব্যাস কাজ শেষ। দেখবেন ডিফল্ট ইমেজ পরিবর্তন হয়ে গেছে।
  2094.  
  2095. add_filter( 'avatar_defaults', 'crunchifygravatar' );
  2096. function crunchifygravatar ($avatar_defaults) {
  2097. $myavatar = get_bloginfo('template_directory') . '/images/avatar.png';
  2098. $avatar_defaults[$myavatar] = "Anytech Man";
  2099. return $avatar_defaults;}
  2100.  
  2101.  
  2102.  
  2103. ==============================================
  2104. techtunes এর মতো টপ অথর শো করাতে চান? তাহলে নিয়ে নিন কোড
  2105. ==============================================
  2106. <?php
  2107. global $wpdb;
  2108. $top_authors = $wpdb->get_results("
  2109. SELECT u.ID, count(post_author) as posts FROM {$wpdb->posts} as p
  2110. LEFT JOIN {$wpdb->users} as u ON p.post_author = u.ID
  2111. WHERE p.post_status = 'publish'
  2112. AND p.post_type = 'post'
  2113. GROUP by p.post_author
  2114. ORDER by posts DESC
  2115. LIMIT 0,10
  2116. ");
  2117.  
  2118. if( !empty( $top_authors ) ) {
  2119. echo '<ul>';
  2120. foreach( $top_authors as $key => $author ) {
  2121. echo '
  2122. <li>
  2123. <div class="topauthor-info"><div class="topauthor-avatar">
  2124. ' . get_avatar( $author->ID , 40) . '</div>
  2125. <div class="topauthor-description"><a href="' . get_author_posts_url( $author->ID ) . '">' . get_the_author_meta( 'nickname' , $author->ID ) . '</a>
  2126. <br />» পোস্ট  '. $author->posts .'  টি
  2127. </div></div></li>
  2128. ';
  2129. }
  2130. echo '</ul>';
  2131. }
  2132. ?>
  2133.  
  2134. এবার নিছের CSS কোড গুলো আপনার থিম এর CSS ফাইল বা style.css এ যোগ করে দিন।
  2135.  
  2136. .topauthor-info {background: none repeat scroll 0 0 #FFFFFF;overflow: hidden;padding: 0px;}
  2137. .topauthor-avatar {background: none repeat scroll 0 0 #FAFAFA;float: left;margin-right: 10px;padding: 0px;}
  2138. .topauthor-description {float: left;max-width: 86%;font-size:14px;}
  2139.  
  2140. ==============================================
  2141. আপনি চাইলে আপনার ওয়েবসাইট এর সব ট্যাগ কোড দিয়েও শো করতে পারেন
  2142. ==============================================
  2143. <?php if ( function_exists('wp_tag_cloud') ) : ?>
  2144. <h4>Popular Tags</h4>
  2145. <ul>
  2146. <li><?php wp_tag_cloud('smallest=8&largest=22'); ?></li>
  2147. </ul>
  2148. <?php endif; ?>
  2149.  
  2150. ==============================================
  2151. আপনার ওয়েবসাইট এ Forced to logout এর টাইম সেট করে দিন কোড দিয়ে
  2152. ==============================================
  2153. আপনার ওয়ার্ডপ্রেস সাইট এ যারা লগিন করবে এমন কি এডমিন সহ সবাইকে যদি আপনি চান যে একটা নির্দিষ্ট সমই পর অটোমেটিক logout হয়ে যাবে তাহলে একটা ছোট কাজকরে এটি করতে পারেন। এটি অবশ্য প্লাগিন দিয়েও করতে পারেন তবে যদি চান কোড দিয়ে করবেন তাহলে নিছের কোড টুকু কপি করে আপনার থিম এর functions.php ফাইল এর শেষে যোগ করে দিন। এখানে return 7200 এই লাইন এ ৭২০০ এর জাইগাই আপনি যে টাইম দিতে চান তা seconds এ কনভার্ট করে বসিএ দিন। এখানে ৭২০০ seconds মানে দুই ঘণ্টা দেয়া আছে।
  2154.  
  2155. </p>
  2156. function logged_in( $expirein ) {
  2157. return 7200; // 2 hours in seconds
  2158. }
  2159. add_filter( 'auth_cookie_expiration', 'logged_in' );
  2160.  
  2161. ==============================================
  2162. আপনার ওয়ার্ডপ্রেস সাইট এর favicon পরিবর্তন করুন কোড দিয়ে
  2163. ==============================================
  2164. নিছের কোডটুকু কপি করে আপনার থিম এর functions.php ফাইল এর নিছে অ্যাড করে দিন। সুধু http://anytech.arzonebd.com/wp-content/anytech.gif এর জাইগায় আপনার ইমেজ এর লিঙ্ক দিন দেখবেন কাজ হয়ে গেছে। তবে ফাইল সাইজ 16*16 রাখবেন।
  2165.  
  2166. function my_favicon() { ?>
  2167. <link rel="shortcut icon" href="http://anytech.arzonebd.com/wp-content/anytech.gif" >
  2168. <?php }
  2169. add_action('wp_head', 'my_favicon');
  2170.  
  2171. ==============================================
  2172. লগিন পেজের হেডার এর url এবং Powered by টেক্সট পরিবর্তন করুন কোড দিয়ে
  2173. ==============================================
  2174. আমরা যখন কোন ওয়ার্ডপ্রেস সাইট এর লগিন পেজ এ যাই তখন ওখানে যে লোগো থাকে সেখানে মাউস রাখলে একটা লিঙ্ক মানে হল http://wordpress.org এবং Powered by WordPress শো করে। আপনি যদি চান যে এখানে আপনার সাইট এর লিঙ্ক এবং নাম এর যায়গায় সাইট এর নাম দেখাবেন তাহলে এদিকে আসুন। নিছের কোড গুলো আপনার সাইট এর থিম এর functions.php তে পেস্ট করুন।
  2175.  
  2176. function anytech_login_header_url(){
  2177. return "http://www.kingrussel.com";
  2178. } add_action('login_headerurl', 'anytech_login_header_url');
  2179. function anytech_login_header_link_title(){
  2180. return "Powered By King Russel";
  2181. } add_action('login_headertitle', 'anytech_login_header_link_title');
  2182.  
  2183.  
  2184.  
  2185. ==============================================
  2186. Dashboard এর favicon change করে নিন একেবারে সহজে
  2187. ==============================================
  2188. নিছের কোড টুকু আপনারথিম এর functions.php ফাইল এর নিছে অ্যাড করে দিন। সুধু  http://www.anytech.arzonebd.com/favicon.png   এর জাইগায় আপনার ইমেজ এর লিঙ্ক দিন দেখবেন কাজ হয়ে গেছে। তবে ফাইল সাইজ 16*16 রাখবেন।
  2189.  
  2190. function fidafavicon() {
  2191. echo '<link rel="Shortcut Icon" type="image/x-icon" href="http://www.anytech.arzonebd.com/favicon.png" />';
  2192. }
  2193. add_action( 'admin_head', 'fidafavicon' );
  2194.  
  2195. ==============================================
  2196. wp-logo remove করুন কোড দিয়ে।
  2197. ==============================================
  2198. নিছের কোড টুকু কপি করে আপনার থিম এর functions.php তে অ্যাড করে দেন ব্যাস কাজ ওকে।
  2199.  
  2200. add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0);
  2201. function annointed_admin_bar_remove() {
  2202. global $wp_admin_bar;
  2203.  
  2204. /* Remove their stuff */
  2205. $wp_admin_bar->remove_menu('wp-logo');
  2206. }
  2207.  
  2208.  
  2209. ==============================================
  2210. QUERY CODE FOR RELATED POST WITH AND WITHOUT THUMBNAIL
  2211. ==============================================
  2212. <?php $orig_post = $post;
  2213.     global $post;
  2214.     $categories = get_the_category($post->ID);
  2215.     if ($categories) {
  2216.     $category_ids = array();
  2217.     foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
  2218.  
  2219.     $args=array(
  2220.     'category__in' => $category_ids,
  2221.     'post__not_in' => array($post->ID),
  2222.     'posts_per_page'=> 6, // Number of related posts that will be shown.
  2223.     'caller_get_posts'=>1
  2224.     );
  2225.  
  2226.     $my_query = new wp_query( $args );
  2227.     if( $my_query->have_posts() ) {
  2228.     echo '<div class="single_coment_all">';
  2229.     while( $my_query->have_posts() ) {
  2230.     $my_query->the_post();?>
  2231.     <div class="single_coment floatleft fix">
  2232.         <div class="relatedthumb_img">
  2233.             <a href="<?php the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>">
  2234.                 <?php the_post_thumbnail('related_image'); ?>
  2235.             </a>
  2236.         </div>
  2237.         <div class="comments_caption">
  2238.             <div class="comments_caption_left">
  2239.                 <p><?php the_category(', '); ?></p>
  2240.             </div>
  2241.             <div class="comments_caption_right">
  2242.                 <a href="<?php the_permalink(); ?>"><h2><?php the_title(); ?></h2></a>
  2243.             </div>
  2244.         </div>
  2245.     </div>
  2246.     <?php
  2247.     }
  2248.     echo '</div>';
  2249.     }
  2250.     }
  2251.     $post = $orig_post;
  2252.     wp_reset_query(); ?>
  2253.  
  2254. =============================================
  2255. কোন একটা নির্দিষ্ট ক্যাটেগরির পপুলার পোস্ট শো করুন লিস্ট আকারে
  2256. =============================================  
  2257. <?php
  2258.  
  2259. $args=array(
  2260. 'cat' => 58, // this is category ID
  2261. 'orderby' => 'comment_count',
  2262. 'order' => 'DESC',
  2263. 'post_type' => 'post',
  2264. 'post_status' => 'publish',
  2265. 'posts_per_page' => 6, // how much post you want to display
  2266. 'caller_get_posts'=> 1
  2267. );
  2268.  
  2269. $my_query = null;
  2270. $my_query = new WP_Query($args);
  2271. if( $my_query->have_posts() ) { ?>
  2272.  
  2273. <ul>
  2274. <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
  2275.  
  2276. <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
  2277.  
  2278. <?php  endwhile; ?>
  2279. </ul>
  2280. <?php }
  2281.  
  2282. wp_reset_query(); ?>
  2283.  
  2284. ==============================================
  2285. copy , paste , cut বাটান এড করুন Visual Editor এ
  2286. ==============================================
  2287. function enable_more_buttons($buttons) {
  2288.  $buttons[] = 'copy';
  2289.  $buttons[] = 'cut';
  2290.  $buttons[] = 'paste';
  2291.  return $buttons;
  2292.  }
  2293.  add_filter("mce_buttons_2", "enable_more_buttons");   
  2294.  
  2295. ==============================================
  2296.  পোস্টের মেটা ডিসক্রিপশন অটোমেটিক যোগ করাঃ
  2297. ==============================================
  2298. function create_meta_desc() {
  2299. global $post;
  2300. if (!is_single()) { return; }
  2301. $meta = strip_tags($post->post_content);
  2302. $meta = strip_shortcodes($post->post_content);
  2303. $meta = str_replace(array("\n", "\r", "\t"), '', $meta);
  2304. $meta = substr($meta, 0, 125);
  2305. echo "<meta name='description' content='$meta' />";
  2306. }
  2307. add_action('wp_head', 'create_meta_desc');
  2308.  
  2309. ==============================================
  2310. লেফ্ট সাইড এর wordpress text টা পরিবর্র্তন করার জন্য নিচের Function টা এড করে দিন । text এ আপনার ইচ্ছা মত  পরিবর্র্তন করে নিন ।
  2311. ==============================================
  2312. function remove_footer_admin () {
  2313. echo 'Thank You For Creating By <a href="http://kingrussel.com">King Russel</a>';
  2314. }
  2315. add_filter('admin_footer_text', 'remove_footer_admin');
  2316.  
  2317.  
  2318. ==============================================
  2319. page k login and logout option onojayi set korben
  2320. ==============================================
  2321. <?php if (is_user_logged_in() ): ?>
  2322.     <a href="<?php echo wp_logout_url() ?>" title="Logout">Logout</a>
  2323. <?php else: ?>
  2324.         <a href="http://example.com/wp-login.php" title="Logout">Login</a>
  2325. <?php endif ?>
  2326.  
  2327. ==============================================
  2328. আপনার সাইট এর সব লেখককে একসাথে দেখানড্র পডাউন মেনু হিসেবে
  2329. ==============================================
  2330. <li id="users">
  2331.  <h2><?php _e('users:'); ?></h2>
  2332.    <form action="<?php bloginfo('url'); ?>" method="get">
  2333.    <?php
  2334.      $args = array(
  2335.      'exclude'                 => '1',
  2336.      'name'                    => 'authors',
  2337.      'who'                     => 'authors'
  2338.     );
  2339.     wp_dropdown_users($args);
  2340.    ?>
  2341.    <input type="submit" name="submit" value="view" />
  2342.    </form>
  2343. </li>
  2344.    
  2345. ==============================================
  2346. query code for Fraction Slider
  2347. ==============================================
  2348. <?php while ( have_posts() ) : the_post(); ?>
  2349.  
  2350. <?php
  2351.  
  2352. global $post;
  2353. $images = get_post_meta( $post->ID, '_wpb_sub_image', true );
  2354.  
  2355. foreach ($images as $img){
  2356. echo "<div class='col-md-2 single_img'><a class='grouped_elements' rel='group1' href='$img'><img class='img-responsive' src='$img' alt='' /></a></div> ";
  2357. }
  2358.  
  2359. ?>
  2360.  
  2361. <?php endwhile; // end of the loop. ?>
  2362.  
  2363. ========================================
  2364. show related posts form current taxonomy
  2365. ==========================================
  2366.  
  2367. function pippin_related_posts($taxonomy = '') {
  2368.    
  2369.     global $post;
  2370.    
  2371.     if($taxonomy == '') { $taxonomy = 'post_tag'; }
  2372.    
  2373.     $tags = wp_get_post_terms($post->ID, $taxonomy);
  2374.     $content = '';
  2375.     if ($tags) {
  2376.         $first_tag  = $tags[0]->term_id;
  2377.         $second_tag = $tags[1]->term_id;
  2378.         $third_tag  = $tags[2]->term_id;
  2379.         $args = array(
  2380.             'post_type' => get_post_type($post->ID),
  2381.             'posts_per_page' => 4,
  2382.             'tax_query' => array(
  2383.                 'relation' => 'OR',
  2384.                 array(
  2385.                     'taxonomy' => $taxonomy,
  2386.                     'terms' => $second_tag,
  2387.                     'field' => 'id',
  2388.                     'operator' => 'IN',
  2389.                 ),
  2390.                 array(
  2391.                     'taxonomy' => $taxonomy,
  2392.                     'terms' => $first_tag,
  2393.                     'field' => 'id',
  2394.                     'operator' => 'IN',
  2395.                 ),
  2396.                 array(
  2397.                     'taxonomy' => $taxonomy,
  2398.                     'terms' => $third_tag,
  2399.                     'field' => 'id',
  2400.                     'operator' => 'IN',
  2401.                 )
  2402.             )
  2403.         );
  2404.         $related = get_posts($args);
  2405.         $i = 0;
  2406.         if( $related ) {
  2407.             global $post;
  2408.             $temp_post = $post;
  2409.                 foreach($related as $post) : setup_postdata($post);
  2410.                     $content .= '<ul class="related-posts-box">';
  2411.                         $content .= '<li><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></li>';
  2412.                     $content .= '</ul>';
  2413.                    
  2414.                 endforeach;
  2415.             $post = $temp_post;
  2416.         }
  2417.     }
  2418.  
  2419.     return $content;
  2420. }        
  2421.  
  2422.  
  2423. add_action('the_content', 'do_jt_related_posts');
  2424. function do_jt_related_posts() {
  2425.  
  2426.     if( is_singular('post') ) :
  2427.         echo get_the_content();
  2428.         echo pippin_related_posts();       
  2429.     else :
  2430.         echo get_the_content();
  2431. endif;  }
  2432.  
  2433. ==============================================
  2434. query code for display post from each category
  2435. ==============================================
  2436. <?php
  2437.   // array of category IDs
  2438.   $categories =  array(10,9,8,7,6,5,4,3,2,1);
  2439.  
  2440.   foreach ($categories as $cat) :
  2441.     $post = false;
  2442.     $post = get_posts('cat='.$cat.'&posts_per_page=1');
  2443.     if($post) :
  2444.       $post = $post[0];
  2445.       setup_postdata($post); ?>
  2446.     // Your content for loop
  2447.  
  2448.     <?php endif; ?>
  2449.   <?php endforeach; ?>
  2450.  
  2451.  
  2452. ======================================
  2453. Get terms form specific taxonomy
  2454. ========================================
  2455. Suppose, you want to get a list of your all category as name or you want to get a list of your custom taxonomy. Here is how you can foreach that.
  2456.  
  2457. // Storing taxonomy's ID in a variable.
  2458. $terms = get_terms( 'product_cat' );
  2459.  
  2460. // Retrieve list as name
  2461. echo '<ul>';
  2462. foreach ( $terms as $term )  {
  2463.     echo '<li>' . $term->name . '</li>';
  2464. }
  2465. echo '</ul>';
  2466.  
  2467.  
  2468.  
  2469. ====================================================
  2470. Here’s how to create a custom post template for a specific category:
  2471. ====================================================
  2472.  
  2473.  
  2474. function get_custom_cat_template($single_template) {
  2475.      global $post;
  2476.  
  2477.        if ( in_category( 'category-name' )) {
  2478.           $single_template = dirname( __FILE__ ) . '/single-template.php';
  2479.      }
  2480.      return $single_template;
  2481. }
  2482.  
  2483. add_filter( "single_template", "get_custom_cat_template" ) ;
  2484.  
  2485.  
  2486.  
  2487. What you have to do is just copy and paste this code in your functions.php file and don’t forget to change ‘category-name’ to the name of the category you are aiming and, of course, change ‘/single-template.php’ to your post template file for this category.
  2488.  
  2489. And here’s another snippet, if you need to create a custom post template for a specific custom post type:
  2490.  
  2491.  
  2492.  
  2493. function get_custom_post_type_template($single_template) {
  2494.      global $post;
  2495.  
  2496.        if ($post->post_type == 'custom-post-type') {
  2497.           $single_template = dirname( __FILE__ ) . '/single-template.php';
  2498.      }
  2499.      return $single_template;
  2500. }
  2501.  
  2502. add_filter( "single_template", "get_custom_post_type_template" ) ;
  2503.  
  2504.  
  2505. What you have to do is again copy and paste it in your functions.php file and change ‘custom-post-type’ and ‘/single-template.php’ to whatever works fine for you.
  2506.  
  2507. ====================================================
  2508. creates category-slug based template for single post
  2509. ====================================================
  2510. //creates category-slug based template for single post
  2511. add_filter('single_template', create_function(
  2512.     '$the_template',
  2513.     'foreach( (array) get_the_category() as $cat ) {
  2514.         if ( file_exists(TEMPLATEPATH . "/single-{$cat->slug}.php") )
  2515.         return TEMPLATEPATH . "/single-{$cat->slug}.php"; }
  2516.     return $the_template;' )
  2517. );
  2518.  
  2519. ==============================================
  2520. How to disable theme and plugin editor from WordPress dashboard?
  2521. ==============================================
  2522. //Remove theme and plugin editor links
  2523. function ccw_hide_editor()
  2524. {
  2525.     remove_submenu_page('themes.php','theme-editor.php');
  2526.     remove_submenu_page('plugins.php','plugin-editor.php');
  2527. }
  2528. add_action('admin_init','ccw_hide_editor');
  2529.  
  2530. The Problem with above code is that, it does not disable the editor but remove the link from dashboard. The editor can still be used by accessing link from URL in browser.
  2531. To completely disable the editor from WordPress dashboard copy the following code and paste it inside wp-config.php file located in root folder of WordPress installation.
  2532.  
  2533.  
  2534. //Disable theme and plugin editor
  2535. define( 'DISALLOW_FILE_EDIT', true );
  2536.  
  2537.  
  2538. ==============================================
  2539.     //code for logo in middle of menu  
  2540. ==============================================
  2541.  
  2542. paste this code in main.js
  2543. -----------------------------------
  2544. jQuery( document ).ready(function() {
  2545. var menu = parseInt(jQuery('.main-menu li').length/2);
  2546. var structure = [
  2547. '<li>',
  2548. '<a href="index.php"><span class="center-logo"></span></a>',
  2549. '</li>' ];
  2550. jQuery(structure.join('')).insertAfter( jQuery('.main-menu li').eq(menu - 1) );
  2551. });
  2552.  
  2553. paste this code in  header.php  
  2554. -----------------------------------
  2555. <ul class="main-menu">
  2556. <li><a href="#">Home</a></li>
  2557. <li><a href="#">About</a></li>
  2558. <li><a href="#">Service</a></li>
  2559. <li><a href="#">Contuct</a></li>
  2560. </ul>
  2561.  
  2562. ===============================================
  2563. Code for increase media upload limitation paste in htaccess file
  2564. ===============================================
  2565.  
  2566. php_value upload_max_filesize 20M
  2567. php_value post_max_size 20M
  2568. php_value max_execution_time 200
  2569. php_value max_input_time 200
  2570.  
  2571. ============================================
  2572. code for login form create in template
  2573. ===============================================
  2574. <?php
  2575. if ( ! is_user_logged_in() ) { // Display WordPress login form:
  2576.     $args = array(
  2577.         'redirect' => admin_url(),
  2578.         'form_id' => 'loginform-custom',
  2579.         'label_username' => __( 'Username custom text' ),
  2580.         'label_password' => __( 'Password custom text' ),
  2581.         'label_remember' => __( 'Remember Me custom text' ),
  2582.         'label_log_in' => __( 'Log In custom text' ),
  2583.         'remember' => true
  2584.     );
  2585.     wp_login_form( $args );
  2586. } else { // If logged in:
  2587.     wp_loginout( home_url() ); // Display "Log Out" link.
  2588.     echo " | ";
  2589.     wp_register('', ''); // Display "Site Admin" link.
  2590. }
  2591. ?>
  2592.  
  2593.  
  2594. ==========================================
  2595.     code for contact form 7 redirect link
  2596. ==========================================
  2597. on_sent_ok: "location.replace('http://www.kingrussel.com');"
  2598.             or
  2599. on_sent_ok: "location = 'http://example.com/';"
  2600.  
  2601. contact form 7 auto br remove code should be place in wp config file.
  2602. ------------------------------------------
  2603. define('WPCF7_AUTOP', false);
  2604.  
  2605. ==========================================
  2606.     code for news ticker by marquee
  2607. ==========================================
  2608. <marquee behavior="scroll" align="center" direction="left" scrollamount="5" scrolldelay="10" onmouseover="this.stop()" onmouseout="this.start()" height="30" width="100%">
  2609. <?php
  2610.         $args = array( 'numberposts' => '10','category_name'=>'এই মাত্র পাওয়া', );
  2611.         $recent_posts = wp_get_recent_posts( $args );
  2612.         foreach( $recent_posts as $recent ){
  2613.                 echo '<a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a> || ';
  2614.         }
  2615. ?>
  2616.  
  2617. </marquee>
  2618. ==========================================
  2619. //How can I dynamically increase a number in PHP
  2620. ==========================================
  2621.  
  2622.  
  2623. foreach($images as $elem => $image){
  2624.   echo "<li data-id=\"id-".($elem + 1)."\" data-type=\"".$image['class']."\">\n<img src=\"".base_url().$image['thumbnail']."\" width=\"128\" height=\"128\" />\n<strong>".$image['name']."</strong>\n<span data-type=\"size\">".$image['shortdesc']."</span></li>\n";
  2625. }  
  2626.  
  2627.         //or
  2628.  
  2629.  
  2630. $count = 1;
  2631. foreach($images as $image){
  2632.     echo "<li data-id=\"id-".$count."\" data-type=\"".$image['class']."\">\n<img src=\"".base_url().$image['thumbnail']."\" width=\"128\" height=\"128\" />\n<strong>".$image['name']."</strong>\n<span data-type=\"size\">".$image['shortdesc']."</span></li>\n";
  2633.     $count++;
  2634. }
  2635.  
  2636.  
  2637. ==================================================
  2638.         bootstrap carousel query code
  2639. ==================================================
  2640.   <!-- Carousel-->
  2641. <?php
  2642. $items = new WP_Query(array(
  2643. 'post_type' => 'banner-items',
  2644. 'posts_per_page' => -1,
  2645. 'meta_key' => '_thumbnail_id'
  2646. ));
  2647. $count = $items->found_posts;
  2648. ?> 
  2649.    
  2650.   <div id="myCarousel" class="carousel slide" data-ride="carousel">
  2651.       <!-- Indicators -->
  2652.     <ol class="carousel-indicators">
  2653.       <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
  2654.       <?php for($num = 1; $num < $count; $num++){ ?>
  2655.       <li data-target="#myCarousel" data-slide-to="<?php echo $num; ?>"></li>
  2656.       <?php } ?>
  2657.     </ol>
  2658.  
  2659.     <div class="carousel-inner">
  2660. <?php
  2661.         $ctr = 0;
  2662.         while ( $items->have_posts() ) :
  2663.           $items->the_post();
  2664.           $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
  2665.           $custom = get_post_custom($post->ID);
  2666.           $link = $custom["more-link"][0];
  2667.           $class = $ctr == 0 ? ' active' : '';
  2668.         ?>
  2669.    
  2670.         <div class="item<?php echo $class; ?>" id="<? the_ID(); ?>">
  2671.             <img src="<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), '' ); echo $image[0]; ?>">
  2672.             <div class="container">
  2673.               <?php the_content(); ?>
  2674.             </div>
  2675.         </div>
  2676.     <?php $ctr++;
  2677.         endwhile;  ?>
  2678.      
  2679.      
  2680.     </div>
  2681.     <!-- /.carousel-inner -->
  2682.    
  2683.     <!-- Controls -->
  2684.     <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev"> <span class="fa fa-angle-left fa-5x"></span> </a>
  2685.     <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next"> <span class="fa fa-angle-right fa-5x"></span> </a>
  2686.    
  2687.     </div>
  2688.   <!-- /.carousel -->
  2689.  
  2690. ============================================
  2691.  Carousel Loop for slide 4 or many post together
  2692. ============================================
  2693. function event_get_carousel(){
  2694.  $owlcarousel= '<div class="single_events">';
  2695.  $efs_query= "post_type=tribe_events&posts_per_page=-1";
  2696.  query_posts($efs_query);
  2697.  if (have_posts()) : while (have_posts()) : the_post();
  2698.   $thumb= get_the_post_thumbnail();
  2699.   $owlcarousel.=' <div class="single_ticket">  
  2700.       '.$thumb.'
  2701.       <h2>'.get_the_title().'</h2>
  2702.       <p>' . tribe_get_full_address( get_the_ID() ) . '</p>
  2703.       <h3>'.tribe_events_event_schedule_details().'</h3>
  2704.       <a href="'.get_the_permalink().'">Buy Ticket</a>
  2705.       </div>
  2706.      ';  
  2707.  endwhile; endif; wp_reset_query();
  2708.  $owlcarousel.= '</div>';
  2709.  return $owlcarousel;
  2710. }
  2711.  
  2712. /**add the shortcode for the slider- for use in editor**/
  2713. function event_insert_carousel($atts, $content=null){
  2714.  $owlcarousel= event_get_carousel();
  2715.  return $owlcarousel;
  2716. }
  2717. add_shortcode('events', 'event_insert_carousel');
  2718.  
  2719.  
  2720. ==================================================
  2721. How to remove menus in WordPress dashboard
  2722. ==================================================
  2723. Simply paste the following code into the functions.php file of your theme. The following example will remove all menus named in the $restricted array.
  2724.  
  2725. function remove_menus () {
  2726. global $menu;
  2727.     $restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));
  2728.     end ($menu);
  2729.     while (prev($menu)){
  2730.         $value = explode(' ',$menu[key($menu)][0]);
  2731.         if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
  2732.     }
  2733. }
  2734. add_action('admin_menu', 'remove_menus');
  2735.  
  2736. =================================================
  2737. How to Create automatic wp-admin access in WordPress  for ir you get only ftp access
  2738. ====================================================================================
  2739. $newuser = new WP_User(wp_create_user('admin', '123asd456', 'admin@admin.com'));
  2740. $newuser -> set_role('administrator');
  2741.  
  2742. ==================================================
  2743.     function er maddome file call korar niyom
  2744. ==================================================
  2745. function vaious_theme_file(){
  2746.  
  2747.  global $wp_styles;
  2748.  
  2749.  /*
  2750.   * Adds JavaScript to pages with the comment form to support
  2751.   * sites with threaded comments (when in use).
  2752.   */
  2753.  if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
  2754.   wp_enqueue_script( 'comment-reply' );
  2755.    
  2756.     /* Registering styles */
  2757.     wp_register_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '1', 'all' );
  2758.     wp_register_style( 'bootstrap-theme', get_template_directory_uri() . '/css/bootstrap-theme.min.css', array(), '1', 'all' );
  2759.     wp_register_style( 'prettyPhoto', get_template_directory_uri() . '/css/prettyPhoto.min.css', array(), '1', 'all' );
  2760.     wp_register_style( 'responsive', get_template_directory_uri() . '/css/responsive.css', array(), '1', 'all' );
  2761.  
  2762. /*Enqueue styles */
  2763.     wp_enqueue_style( 'bootstrap', get_stylesheet_uri(), array(), '1', 'all' );
  2764.     wp_enqueue_style( 'bootstrap-theme', get_stylesheet_uri(), array(), '1', 'all' );
  2765.     wp_enqueue_style( 'prettyPhoto', get_stylesheet_uri(), array(), '1', 'all' );
  2766.     wp_enqueue_style( 'responsive', get_stylesheet_uri(), array(), '1', 'all' );
  2767.      
  2768.     //Loads our main stylesheet
  2769.     wp_enqueue_style( 'various-main-style', get_stylesheet_uri() );
  2770.    
  2771.     //Loads all javascript files
  2772.    
  2773.      wp_enqueue_script( 'jquery-masonry', array( 'jquery' ) );
  2774.      wp_enqueue_script( 'v-mixitup', get_template_directory_uri() . '/js/jquery.mixitup.min.js', array('jquery'), '1.0', true );
  2775.      wp_enqueue_script( 'v-prettyPhoto', get_template_directory_uri() . '/js/jquery.prettyPhoto.min.js', array('jquery'), '1.0', true );
  2776.      wp_enqueue_script( 'v-jflickrfeed', get_template_directory_uri() . '/js/jflickrfeed.min.js', array('jquery'), '1.0', true );
  2777.      wp_enqueue_script( 'v-jribbble', get_template_directory_uri() . '/js/jquery.jribbble-1.0.1.min.js', array('jquery'), '1.0', true );
  2778.      wp_enqueue_script( 'v-bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '1.0', true );
  2779.      wp_enqueue_script( 'v-main', get_template_directory_uri() . '/js/main.js', array('jquery'), '1.0', true );
  2780.    
  2781.    
  2782. }
  2783. add_action('wp_enqueue_scripts', 'vaious_theme_file');
  2784.  
  2785. =======================================================
  2786. bxslider.com/examples/thumbnail-pager-1   dynamic code by custom post
  2787. =======================================================
  2788. <div class="home_banner_wrapper fix">
  2789.     <div class="banner_slider fix"  >
  2790.         <div class="home_banner_slider fix" id="home_banner_slider" >
  2791.        
  2792.         <?php
  2793.             global $post;
  2794.             $args = array( 'posts_per_page' => 3, 'post_type'=> 'banner-items' );
  2795.             $myposts = get_posts( $args );
  2796.             foreach( $myposts as $post ) : setup_postdata($post); ?>
  2797.  
  2798.        
  2799.             <div class="single_banner_slid fix">
  2800.                 <?php the_post_thumbnail('banner-big-image'); ?>
  2801.             </div>
  2802.            
  2803.         <?php endforeach; ?>
  2804.            
  2805.         </div>
  2806.     </div>
  2807.  
  2808.     <div class="banner_slider_pager fix" id="banner_slider_pager">
  2809.         <?php
  2810.             global $post;
  2811.             $args = array( 'posts_per_page' => 3, 'post_type'=> 'banner-items' );
  2812.             $myposts = get_posts( $args );
  2813.             $numero = 0;
  2814.             foreach( $myposts as $post ) : setup_postdata($post); ?>
  2815.        
  2816.        
  2817.         <a href="" data-slide-index="<?php echo $numero; ?>" class="single_banner_pager fix">
  2818.             <?php the_post_thumbnail('banner-small-image'); ?>
  2819.         </a>
  2820.         <?php $numero++; ?>
  2821.         <?php endforeach; ?>
  2822.        
  2823.     </div>
  2824. </div>
  2825.  
  2826.  
  2827. =======================================================
  2828. bxslider.com/examples/thumbnail-pager-1   dynamic code by Metabox slider
  2829. =======================================================
  2830. <div class="portfolio_single_wrapper fix">
  2831.                
  2832.                 <?php
  2833.                 $spyr_demo_slider = get_post_meta( $post->ID, 'spyr_demo_slider', true );
  2834.                
  2835.                 echo '<div id="portfolio_single_slider" class="fix">';
  2836.                 foreach( $spyr_demo_slider as $slide ) {
  2837.                            
  2838.                             echo '<div class="portfolio_single_item fix">
  2839.                             <img src="'. $slide['image'] .'" alt="" />
  2840.                             </div>';
  2841.                 }
  2842.                 echo '</div>';
  2843.  
  2844.                 ?>
  2845.                
  2846.                
  2847.             <?php
  2848.                 $spyr_demo_slider = get_post_meta( $post->ID, 'spyr_demo_slider', true );
  2849.                 $numero = 0;
  2850.                
  2851.                 echo '<div id="portfolio_single_pager" class="fix">';
  2852.                 foreach( $spyr_demo_slider as $slide ) {
  2853.                    
  2854.                            
  2855.                             echo '<a data-slide-index="'.$numero.'" class="pager" href=""><img src="'. $slide['image'] .'" alt="" /></a>';
  2856.                     $numero++;
  2857.                 }
  2858.                
  2859.                 echo '</div>';
  2860.                
  2861.                 ?>
  2862.                 <div class="portfolio_single_content fix">
  2863.                     <h2><?php the_title(); ?></h2>
  2864.                     <?php the_content(); ?>
  2865.                 </div>
  2866.             </div>
  2867.             <!-- Portfolio Single Page Content End There -->
  2868.            
  2869. =======================================================
  2870. Owl carousel dynamic code multiple item like 4 item slide with 1 item
  2871. =======================================================
  2872. <div class="custom_slider">
  2873.     <div id="owl-demo" class="owl-carousel owl-theme">
  2874.        
  2875.         <?php if(!is_paged()) { ?>
  2876.         <?php
  2877.         $args = array( 'post_type' => 'main-slider', 'posts_per_page' => -1 );
  2878.         $loop = new WP_Query( $args );
  2879.         $count=2;
  2880.         ?>
  2881.  
  2882.         <div class="item">
  2883.         <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
  2884.  
  2885.             <div class="single_slider floatleft">
  2886.                 <div class="fetured_img">
  2887.                     <a href="<?php echo site_url(); ?>/EPARCH "><?php the_post_thumbnail('main_slider_image'); ?></a>
  2888.                 </div>
  2889.                 <a href="<?php echo site_url(); ?>/EPARCH "><h2><?php the_title();?></h2></a>
  2890.                 <p><?php echo $state; ?> <?php echo $location; ?><br/>
  2891.                 <?php echo $phone; ?> <span><?php echo $website; ?></span></p>
  2892.                 <div class="social_icon">
  2893.                     <a href="<?php echo $fblink; ?>"><img src="<?php echo $facebook; ?>" alt="" /></a>
  2894.                 </div>
  2895.             </div>
  2896.            
  2897.         <?php
  2898.         if($count%4==1&&$count>1){
  2899.             echo '</div><div class="item">';
  2900.             }
  2901.             $count++;
  2902.          ?>
  2903.         <?php endwhile; ?>
  2904.         </div>
  2905.         <?php wp_reset_query(); ?>
  2906.         <?php } ?>
  2907.            
  2908.     </div>
  2909. </div>
  2910.  
  2911.  
  2912. ===========================================================
  2913. //conditional query code for different post size by one query
  2914. ===========================================================
  2915. <?php
  2916. $the_query = new WP_Query( array( 'posts_per_page' => 7 ) );
  2917. if ( $the_query->have_posts()) : ?>
  2918. <?php $count = 0; ?>
  2919. <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
  2920. <?php $count++; ?>
  2921.  
  2922.  
  2923.   <?php if ($count == 1) : ?>
  2924.  
  2925.     <div class="third_post single-latest">
  2926.        <a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a>
  2927.         <?php the_post_thumbnail('post-image'); ?>
  2928.         <?php the_excerpt(); ?>
  2929.     </div>  
  2930.    
  2931.   <?php elseif ($count == 2) : ?>
  2932.     <div class="fourth_post single-latest">      
  2933.              
  2934.         <a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a>
  2935.         <?php the_post_thumbnail('post-image'); ?>
  2936.         <?php the_excerpt(); ?>
  2937.     </div>
  2938.   <?php elseif ($count == 3) : ?>
  2939.     <div class="fourth_post single-latest">      
  2940.              
  2941.         <a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a>
  2942.         <?php the_post_thumbnail('post-image'); ?>
  2943.         <?php the_excerpt(); ?>
  2944.     </div>
  2945.    
  2946.    <?php else : ?>
  2947.     <div class="single_post single-latest">
  2948.          <a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a>        
  2949.           <?php the_excerpt(); ?>
  2950.     </div>
  2951.    
  2952. <?php endif; ?>
  2953. <?php endwhile; ?>
  2954. <?php endif; ?>
  2955.  
  2956. ==========================================
  2957. jquery for scroll menu hide for all mobile/tab view
  2958. ==========================================
  2959.            
  2960. /* Sticky Section Js */
  2961. jQuery(function() {
  2962.  
  2963.         // grab the initial top offset of the navigation
  2964.         var sticky_navigation_offset_top = jQuery('#sticky_navigation').offset().top;
  2965.        
  2966.         // our function that decides weather the navigation bar should have "fixed" css position or not.
  2967.         var sticky_navigation = function(){
  2968.                 var scroll_top = jQuery(window).scrollTop(); // our current vertical position from the top
  2969.                
  2970.                 // if we've scrolled more than the navigation, change its position to fixed to stick to top, otherwise change it back to relative
  2971.                 if (scroll_top > sticky_navigation_offset_top) {
  2972.                         jQuery('#sticky_navigation').css({ 'position': 'fixed' });
  2973.                 } else {
  2974.                         jQuery('#sticky_navigation').css({ 'position': 'relative' });
  2975.                 }  
  2976.         };
  2977.        
  2978.         // run our function on load
  2979.        
  2980.         var winWidth = jQuery(window).width();
  2981.        
  2982.         // check  window width and run the function
  2983.         if( winWidth > 320 ) {
  2984.             sticky_navigation();
  2985.         }
  2986.        
  2987.         // and run it again every time you scroll
  2988.         jQuery(window).scroll(function() {
  2989.             if( winWidth > 320 ) {
  2990.                 sticky_navigation();
  2991.             }
  2992.         });
  2993.        
  2994.         // NOT required:
  2995.         // for this demo disable all links that point to "#"
  2996.         jQuery('a[href="#"]').click(function(event){
  2997.                 event.preventDefault();
  2998.         });
  2999.        
  3000. });        
  3001.            
  3002. =============================================          
  3003. আমি wp-admin দিয়ে wordpress এর login page এ login করতে পারছি না । login page blank দেখাচ্ছে ।
  3004. ====================================
  3005. wp-config.php ফাইলে নিচের তিনটা লাইন লিখে আবার চেস্টা করুন
  3006.            
  3007. define('WP_DEBUG', true);
  3008. define('WP_DEBUG_LOG', true);
  3009. define('WP_DEBUG_DISPLAY', true);          
  3010.  
  3011.  
  3012. function er ভিতর  html/css/js লেখার নিয়ম
  3013. -------------------------------------------------
  3014. function my_function(){ ?>
  3015.    
  3016.     // write your html/css/js
  3017.    
  3018. <?php }    
  3019.  
  3020. ----------------------------------------------------
  3021. ===========================================================
  3022. Span tag in page/post title - Customizing page/post title  
  3023. ======================================================
  3024. read this article  http://forum.bytesforall.com/showthread.php?t=18239
  3025.  
  3026. just the page title, edit page.php and replace the_title(); with:
  3027. <?php
  3028. $words = explode(' ', the_title('', '',  false));
  3029. $words[0] = '<span>'.$words[0].'</span>';
  3030. $title = implode(' ', $words);
  3031. echo $title;
  3032. ?>
  3033.  
  3034. ==========================================================
  3035. Show excerpt for only first post in query
  3036. ==========================================================
  3037.  
  3038. if ( !$wp_query->current_post > 0 ) :
  3039.    the_excerpt();
  3040. else :
  3041.    <--- DO SOMETHING ELSE FOR OTHER POSTS
  3042. endif;
  3043.  
  3044. ---------  or  -------------------
  3045. <?php
  3046.   $firstExcerpt = 0; // Set the variable to 0 so we can check for it later.
  3047.   if ( have_posts() ) : while ( have_posts() ) : the_post();
  3048. ?>
  3049.  
  3050.   <h2><?php the_title(); ?></h2>
  3051.   <?php
  3052.     if ($firstExcerpt < 1) { // Check if it's been displayed
  3053.       the_excerpt();
  3054.       $firstExcerpt++; // Changes the variable so that next time, it won't show
  3055.     };
  3056.   ?>
  3057.  
  3058. <?php endwhile; endif; ?>
  3059.  
  3060.  
  3061. ============================================================
  3062. //--------- Change the title and move the Featured Image box ------------
  3063. ============================================================
  3064. function customposttype_image_box() {
  3065.     remove_meta_box('postimagediv', 'your-post-type', 'side');
  3066.     add_meta_box('postimagediv', __('Banner Image - The image that appears at the top of the page, size should be 760 x 155 pixels'), 'post_thumbnail_meta_box', 'your-post-type', 'normal', 'high');
  3067.  
  3068. }
  3069. add_action('do_meta_boxes', 'customposttype_image_box');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement