Advertisement
firoze

Wordpress code

Oct 28th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 30.88 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html lang="en-US">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title></title>
  6. </head>
  7. <body>
  8.  
  9.  
  10.     <!-- www.underscores.me
  11.         theme generate site যেখান থেকে থিমের সোর্স কোড পাওয়া যায়।
  12.     -->
  13.    
  14.     <!-- title dynamic -->
  15.     <?php bloginfo('name'); ?><?php wp_title(); ?>
  16.    
  17.  
  18.    
  19.     <!-- example -->
  20.     <title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
  21.        
  22.    
  23.     <!-- stylesheet dynamic -->
  24.     <?php bloginfo('stylesheet_url'); ?>
  25.    
  26.    
  27.     <!-- example -->
  28.     <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" media="screen" />
  29.    
  30.    
  31.     <!-- link and image dynamic -->
  32.     <?php echo get_template_directory_uri(); ?>
  33.    
  34.    
  35.  
  36.    
  37.    
  38.    
  39.     <!-- getting wordpress head -->
  40.     <?php wp_head(); ?>
  41.     <?php wp_footer(); ?>
  42.    
  43.     <!-- (Homepage)Welcome Template would be used as Home -->
  44.     <!-- Blog কে Default Template হিসাবে ব্যবহার করতে হবে-->
  45.     <!-- go settings> reading> Front page displays> a static page -->
  46.     <!-- Front page> Home -->
  47.     <!-- Posts page> Blog> save change -->
  48.  
  49.  
  50.  
  51.     <!-- header h1 dynamic -->
  52.    
  53.     <?php bloginfo('title'); ?> - <?php bloginfo('description'); ?>
  54.     example:
  55.     <a class="brand" href="index.html"><?php bloginfo('title'); ?> - <?php bloginfo('description'); ?></a>
  56.    
  57.    
  58.     <!-- menu register -->
  59.     <!-- function register -->
  60.     <!-- >create functions.php and write this code-->
  61.    
  62. <?php
  63.  
  64. add_action('init', 'wpj_register_menu'); /*"fallback menu"*/
  65.  
  66. function wpj_register_menu() {
  67.     if (function_exists('register_nav_menu')) {
  68.         register_nav_menu( 'wpj-main-menu', __( 'Main Menu', 'brightpage' ) );
  69.     }
  70. }
  71. function wpj_default_menu() {
  72.     echo '<ul class="nav pull-right">';         /*"class changeable"*/
  73.     if ('page' != get_option('show_on_front')) {
  74.         echo '<li><a href="'. home_url() . '/">Home</a></li>';
  75.     }
  76.     wp_list_pages('title_li=');
  77.     echo '</ul>';
  78. }  
  79.  
  80. ?>
  81.    
  82.     <!-- then call this menu to header -->
  83. <?php
  84. if (function_exists('wp_nav_menu')) {
  85.     wp_nav_menu(array('theme_location' => 'wpj-main-menu', 'menu_id' => 'dropmenu', 'fallback_cb' => 'wpj_default_menu'));
  86. }
  87. else {
  88.     wpj_default_menu();
  89. }
  90. ?> 
  91.     <!-- 'menu_id' => 'dropmenu' it's changeable //if it were a class then it would be 'menu_class' => 'classname' -->
  92.    
  93.    
  94.     <!-- another menu register code -->
  95.  
  96. <?php
  97.     register_nav_menus( array(
  98.         'mainmenu' => __( 'Mainmenu Menu' ), //mainmenu =register id //Mainmenu Menu = Theme location name
  99.     ) );
  100. ?> 
  101.  
  102.     <!-- then call this menu to header -->
  103.    
  104. <?php wp_nav_menu(array('theme_location' => 'mainmenu', 'menu_class' => 'container')); ?>   <!--menu class is changeable-->
  105.     <!-- or -->
  106.    
  107. <?php
  108. if (function_exists('wp_nav_menu')) {
  109.     wp_nav_menu(array('theme_location' => 'wpj-main-menu', 'menu_id' => 'dropmenu', 'fallback_cb' => 'wpj_default_menu'));
  110. }
  111. else {
  112.     wpj_default_menu();
  113. }
  114. ?> 
  115.  
  116.  
  117.     <!-- wordpress jquery -->
  118.  
  119. <?php
  120. function latest_jquery_call() {
  121.     wp_enqueue_script('jquery');
  122. }
  123. add_action('init', 'latest_jquery_call');
  124. ?>
  125. যখন এই জেকুয়ারি ফাংশনে ব্যবহার করা হবে, তখন index.html এ আগের কল করা জেকুয়ারি ডিলিট করে দিতে হবে।
  126.  
  127. wordpress এ যখন জেকুয়ারি ব্যবহার করা হবে, তখন $ সাইন আর ব্যবহার করা যাবে না।
  128. এর বদলে jQuery ব্যবহার করতে হবে। সব জেকুয়ারি ফাইলেই এটা রিপ্লেস করতে হবে।
  129.     <!-- wordpress jquery -->
  130.    
  131.     <!-- another wordpress jquery -->
  132. <?php
  133. /*eita hoyni
  134. function insert_jquery(){
  135.    wp_enqueue_script('jquery');
  136. }
  137. add_filter('wp_head','insert_jquery');
  138. */
  139.  
  140. //eita kaj hoyese and change $ sign and input there jQuery everywhere
  141. function ppm_lightbox_latest_jquery() {
  142.     wp_enqueue_script('jquery');
  143. }
  144. add_action('init', 'ppm_lightbox_latest_jquery');
  145. ?>
  146.        
  147.    
  148.     <!-- Page.php create -->
  149.     <!--  wordpress এ যেকোন page তৈরি করতে হলে loop ব্যবহার করতে হবে -->
  150.     <!-- নিচের এটা একটা লুপের উদাহরন -->
  151.                     <?php if(have_posts()) : ?><?php while(have_posts())  : the_post(); ?>
  152.                         <div class="post" id="post-<?php the_ID(); ?>">
  153.                                                            
  154.                             <div id="post-title" class="clearfix full">
  155.                                 <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>           
  156.                             </div> <!-- end div .post-title -->
  157.                            
  158.                             <div class="entry">
  159.                            
  160.                                 <?php the_content(); ?>
  161.                                
  162.                                 <div class="space"></div>
  163.                                
  164.                                 <?php get_template_part( 'postmeta' ); // Post Meta (postmeta.php) ?>
  165.                                 <?php wp_link_pages(); ?>
  166.                                 <!-- <?php trackback_rdf(); ?> -->
  167.                            
  168.                             </div> <!-- end div .entry -->
  169.                            
  170.                             <?php comments_template( '', true ); ?>                            
  171.                                
  172.                         </div> <!-- end div .post -->
  173.  
  174.                     <?php endwhile; ?>
  175.  
  176.                     <?php else : ?>
  177.                         <div class="post">
  178.                             <h3><?php _e('404 Error&#58; Not Found', 'brightpage'); ?></h3>
  179.                         </div>
  180.                     <?php endif; ?>
  181.                    
  182.     <!-- লুপ শেশ -->
  183.     <!-- page.php post code -->
  184. <?php if(have_posts()) : ?><?php while(have_posts())  : the_post(); ?> 
  185.  
  186.  
  187.  
  188.  
  189.  
  190. <?php endwhile; ?>
  191.  
  192.  
  193. <?php else : ?>
  194.     <div class="post">
  195.         <h3><?php _e('404 Error&#58; Not Found', 'brightpage'); ?></h3>
  196.     </div>
  197. <?php endif; ?>    
  198.  
  199.  
  200. <!-- Default post query -->
  201.     <!-- এখন লুপের যা দরকার -->
  202.     <?php if(have_posts()) : ?>
  203.         <?php while(have_posts())  : the_post(); ?>
  204.        
  205.                 <!-- Here is div -->
  206.    
  207.    
  208.    
  209.    
  210.     <?php endwhile; ?>
  211.  
  212.     <?php else : ?>
  213.         <section class="four_zero_four">
  214.             <h3><?php _e('404 Error&#58; Not Found', 'brightpage'); ?></h3>
  215.         </section>
  216.     <?php endif; ?>    
  217.    
  218.                    
  219.                        
  220.     <!--  যদি icon দরকার হয়, তবে তার ডাইনামিক কোড -->
  221.    
  222.     <?php
  223.     $icon = get_post_meta($post->ID, 'icon', true);
  224.     ?>
  225.     <?php if($icon) : ?>
  226.          <i class="icon-<?php echo $icon; ?> page-title-icon"></i>
  227.     <?php else : ?>
  228.         <i class="icon-home page-title-icon"></i>
  229.     <?php endif; ?>                
  230.                    
  231.     <!-- Custom field -->
  232.    
  233.     <?php echo get_post_meta($post->ID, 'id', true); ?>
  234.    
  235.     <!-- Custom field variable -->
  236.    
  237. <?php
  238.     $box_icon = get_post_meta($post->ID, 'box_icon', true);
  239.  
  240. ?>
  241.     <?php echo $box_icon; ?>
  242.    
  243.  
  244. <!-- Conditional Custom field use -->
  245.  
  246.  
  247. <?php if($box_icon) : ?>
  248.  
  249.     <div class="pull-left icon-holder">
  250.         <span class="entypo-<?php echo $box_icon; ?>"></span>
  251.     </div>
  252.  
  253. <?php endif; ?>
  254.                        
  255.     <!--  যদি h2 টাইটেলের দরকার হয়, তবে তার ডাইনামিক কোড -->
  256.     <h2><?php the_title(); ?></h2> 
  257.                            
  258.     <!--  যদি p টাইটেলের দরকার হয়, তবে তার ডাইনামিক কোড -->          
  259.     <p><?php echo get_post_meta($post->ID, 'subtitle', true); ?></p>   
  260.                            
  261.     <!--  যদি p টাইটেলের দরকার হয়, তবে if দিয়ে তার ডাইনামিক কোড হবে, (for custom field)--> 
  262.                            
  263.     <!-- সাধারন কোড উদাহরন -->
  264.     <p><?php echo get_post_meta($post->ID, 'Phone', true); ?></p>
  265.    
  266.     <!--if else দিয়ে কোড উদাহরন -->
  267.     <?php
  268.     $Phone = get_post_meta($post->ID, 'Phone', true);
  269.     ?>
  270.     <?php if($Phone) : ?>
  271.          <p><?php echo get_post_meta($post->ID, 'Phone', true); ?></p>
  272.         <?php else : ?>
  273.         <p>need a phone number  </p>                           
  274.     <?php endif; ?>
  275.    
  276.     <!--if  দিয়ে কোড উদাহরন -->
  277.     <?php
  278.     $Phone = get_post_meta($post->ID, 'Phone', true);
  279.     ?>
  280.     <?php if($Phone) : ?>
  281.          <p><?php echo get_post_meta($post->ID, 'Phone', true); ?></p>
  282.                                    
  283.                                    
  284.                                    
  285. <!-- এখন লুপের যা দরকার শেষ-->                                 
  286.  
  287. <!--widget register -->                                
  288.  
  289.  
  290. <!--widget register এর জন্য এই কোডটা functions.php  তে বসাতে হবে -->     
  291. <?php
  292.  
  293. /* Register sidebars and widgetized areas ********************************************/
  294.    
  295.     function brightpage_widget_areas() {
  296.  
  297.         register_sidebar( array(
  298.             'name' => __( 'Footer Left', 'brightpage' ),
  299.             'id' => 'footer_left',
  300.             'description' => __( 'An optional widget area for your welcome message area.', 'brightpage' ),
  301.             'before_widget' => '<div class="big">',
  302.             'after_widget' => '</div>',
  303.             'before_title' => '',
  304.             'after_title' => '',
  305.         ) );
  306.  
  307.     }
  308.     add_action('widgets_init', 'brightpage_widget_areas');
  309.  
  310. ?>
  311.  
  312. <!--widget register এর জন্য এই কোডটা html এ বসাতে হবে-->
  313. <?php dynamic_sidebar('footer_left'); ?>
  314.  
  315. <!-- অথবা -->
  316.  
  317. <!--এই কোডটা html এ বসাতে হবে
  318.     (যদি উইজেড এ লিখা হয় তখন সেটা প্রকাশিত হবে। প্রকাশিত না হলে ডিফল্ট লিখা শো করবে। )-->
  319.     <?php if ( ! dynamic_sidebar( 'footer_left' ) ) : ?>
  320.    
  321.         <!-- এর মধ্যে ডিফল্ট html লিখাগুলি বসিয়ে রাখতে হবে। -->
  322.    
  323.     <?php endif; ?>
  324.  
  325. <!--  যদি title দরকার হয়, তবে তার ডাইনামিক কোড -->   
  326. <?php the_title(); ?>                  
  327. <!--  যদি content দরকার হয়, তবে তার ডাইনামিক কোড -->                     
  328. <?php the_content(); ?>
  329.        
  330.        
  331. <!-- slider  -->
  332. some popular slider
  333. http://codecanyon.net/item/mega-slider-responsive-wordpress-slider-plugin/4673193
  334. http://codecanyon.net/item/layerslider-responsive-wordpress-slider-plugin-/1362246
  335.    
  336. <!-- shortcode wordpress -->
  337. <?php
  338. function youtube_shortcode( $atts, $content = null  ) {
  339.     return '<iframe width="560" height="315" src="//www.youtube.com/embed/'.$content.'" frameborder="0" allowfullscreen></iframe>';
  340. }  
  341. add_shortcode('youtube', 'youtube_shortcode');
  342. ?>
  343. <!-- end shortcode wordpress -->
  344.  
  345.    
  346. <!-- shortcode wordpress -->
  347. 3types of shortcode
  348. [link]content[/link]
  349.  
  350. [link url="http://google.com" title="Google"]
  351.  
  352. [link url="http://google.com"]Google [/link]
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359. <?php
  360.  
  361. function youtube_shortcode( $atts, $content = null  ) {
  362.  
  363.     extract( shortcode_atts( array(
  364.         'width' => '560',
  365.         'height' => '315'
  366.     ), $atts ) );
  367.    
  368.     return '<iframe width="'.$width.'" height="'.$height.'" src="//www.youtube.com/embed/'.$content.'" frameborder="0" allowfullscreen></iframe>';
  369. }  
  370. /*    '.$attribute.'    */
  371.  
  372. add_shortcode('youtube', 'youtube_shortcode');
  373.  
  374. ?>
  375.  
  376. [youtube width="" height=""]sfdfsdf[/youtube]
  377.  
  378. থিমের যেকোন যায়গায় শর্টকোড দিয়ে বাটন ব্যবহার করা যায় এই কোড দিয়ে
  379.  
  380. <?php
  381. function button_shortcode( $atts, $content = null  ) {
  382.  
  383.     extract( shortcode_atts( array(
  384.         'color' => '#4285F4',
  385.         'url' => '',
  386.         'text' => 'Read More',
  387.     ), $atts ) );
  388.  
  389.     return '<a href="'.$url.'" class="s_button" style="background-color:'.$color.'">'.$text.' </a>';
  390. }  
  391. add_shortcode('button', 'button_shortcode');
  392.  
  393.  
  394. ?>
  395.  
  396. অথবা এভাবে
  397.  
  398. <?php
  399. function button_shortcode( $atts, $content = null  ) {
  400.  
  401.     extract( shortcode_atts( array(
  402.         'color' => '#4285F4',
  403.         'url' => '',
  404.         'text' => 'Read More',
  405.         'hover' => '#ddd',
  406.        
  407.     ), $atts ) );
  408.  
  409.     return '
  410.     <style type="text/css">
  411.         a.s_button{background-color:'.$color.'}
  412.         a.s_button:hover{background-color: '.$hover.';}
  413.        
  414.     </style>
  415.     <a href="'.$url.'" class="s_button">'.$text.' </a>';
  416. }  
  417. add_shortcode('button', 'button_shortcode');
  418.  
  419. ?>
  420.  
  421.  
  422. থিমের যেকোন যায়গায় বাটন শর্টকোড ব্যবহার করার অনেক গুলো বাটনে যদি ভিন্ন ভিন্ন কালার দেবার প্রয়োজন হয় সেক্ষেত্রে >বাটনের একটা আই ডি দিতে হবে >আর একটা এ্যাট্রিবিউট রেজিস্টার করতে হবে আই ডি নামে
  423.  
  424. <?php
  425. function button_shortcode( $atts, $content = null  ) {
  426.  
  427.     extract( shortcode_atts( array(
  428.         'color' => '#4285F4',
  429.         'url' => '',
  430.         'text' => 'Read More',
  431.         'hover' => '#ddd',
  432.         'id' => 'btn', /*একটা এ্যাট্রিবিউট রেজিস্টার করতে হবে আই ডি নামে*/
  433.      
  434.     ), $atts ) );
  435.  
  436.     return '
  437.     <style type="text/css">
  438.         এখানে এই লাইন টা চেঞ্জ হবে, নিচের লাইন বসবে, অর্থাৎ স্টাইলশিট ডাইনামিক হবে  a.s_button{background-color:'.$color.'}
  439.         a#button'.$id.'{background-color:'.$color.'}
  440.         এখানে এই লাইন টা চেঞ্জ হবে, নিচের লাইন বসবে, অর্থাৎ স্টাইলশিট ডাইনামিক হবে a.s_button:hover{background-color: '.$hover.';}
  441.         a#button'.$id.':hover{background-color: '.$hover.';}   
  442.     </style>
  443.     <a id="button'.$id.'" /*এখানে বাটনের একটা আই ডি দিতে হবে, তারপর ডাইনামিক কোড দিতে হবে*/ href="'.$url.'" class="s_button">'.$text.' </a>';
  444. }  
  445. add_shortcode('button', 'button_shortcode');
  446.  
  447. ?>
  448.  
  449. [button id="1" url="#" hover="green" text="sample text"]
  450. [button id="2" url="#" hover="green" text="sample text"]
  451. [button id="সবগুলি আইডি ইউনিক হবে, ভিন্ন ভিন্ন কালার দিতে হলে" url="#" hover="green" text="sample text"]
  452.  
  453.  
  454. থিমের যেকোন যায়গায় শর্টকোড ব্যবহার করা যায় এই কোড দিয়ে
  455.  
  456. <?php echo do_shortcode('here is shortcode'); ?>
  457.  
  458.  
  459. কিন্তু উইজেডের ভেতর ডিফল্ট ভাবে শর্টকোড দিলে কাজ করবে না।
  460. এজন্য ফাংশনে একটা ফিল্টার যুক্ত করতে হবে।
  461. functions.php এর মধ্যে নিচের কোডটা দিতে হবে
  462.  
  463. <?php
  464. add_filter('widget_text', 'do_shortcode');
  465. ?>
  466.  
  467.  
  468.  
  469.  
  470.  
  471. <?php
  472. function my_shortcode_handler( $atts, $content = null ) {
  473.     extract( shortcode_atts( array(
  474.         'attr_1' => 'attribute 1 default',
  475.        
  476.     ), $atts ) );
  477. }
  478.  
  479. ?>
  480.  
  481.  
  482.  
  483.  
  484.  
  485. for email sent in wordpress: zpack plugin
  486.  
  487. syntax highlighter wordpress plugin
  488.  
  489. https://wordpress.org/plugins/syntaxhighlighter/installation/
  490.  
  491. http status code
  492. http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
  493.  
  494. <!-- featured image code -->
  495. <?php
  496. add_theme_support( 'post-thumbnails', array( 'post' ) );
  497. ?>
  498.  
  499. <!-- featured image code -->
  500. <?php the_post_thumbnail('post-image', array('class' => 'imgthumb')); ?>
  501.  
  502.  
  503.  
  504.  
  505. <!--  যদি ফিচারড ইমেজ থাকে তবে ফিচারড ইমেজ শো কর, আর যদি ফিচারর্ড ইমেজ না থাকে তবে ডিরেক্টরি থেকে ডিফল্ট ইমেজ শো কর -->
  506.     <?php
  507.         $f_image = the_post_thumbnail('post-image', array('class' => 'imgthumb'));
  508.     ?>
  509.     <?php if($f_image) : ?>
  510.          <?php echo $f_image; ?>
  511.     <?php else : ?>
  512.         <img src="<?php echo get_template_directory_uri(); ?>/img/imagename.jpg" alt="" />
  513.     <?php endif; ?>
  514.  
  515.    
  516. <!--  শর্ট কোড two_column single_column -->  
  517. <?php  
  518. function column_wrapper_shortcode( $atts, $content = null  ) {
  519.  
  520.     extract( shortcode_atts( array(
  521.         'type' => '',
  522.         'text' => 'dfsfds',
  523.        
  524.     ), $atts ) );
  525.  
  526.     return '
  527.     <div class="two_column">'.do_shortcode($content).'</div>   
  528.     ';
  529. }  
  530. add_shortcode('twocol', 'column_wrapper_shortcode');
  531.  
  532. function single_wrapper_shortcode( $atts, $content = null  ) {
  533.  
  534.     extract( shortcode_atts( array(
  535.         'type' => '',
  536.         'text' => '',
  537.        
  538.     ), $atts ) );
  539.  
  540.     return '
  541.     <div class="single_column">'.do_shortcode($content).'</div>
  542.     ';
  543. }  
  544. add_shortcode('scol', 'single_wrapper_shortcode');
  545. ?>
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553. custom post registration (address: http://codex.wordpress.org/Post_Types)
  554.  
  555. <?php
  556. add_action( 'init', 'create_posttype'/*portfolio_custom_post*/ );
  557. function create_posttype() {
  558.     register_post_type( 'acme_product'/*Portfolio Items*/,
  559.         array(
  560.             'labels' => array(
  561.                 'name' => __( 'Products'/*Portfolios*/ ),
  562.                 'singular_name' => __( 'Portfolio' ),
  563.             ),
  564.             'public' => true,
  565.             'has_archive' => true,
  566.             'rewrite' => array('slug' => 'products'/*portfolio-item*/),
  567.         )
  568.     );
  569. }
  570.  
  571. ?>
  572.  
  573. *(add_action( 'init', 'create_posttype' );  > কাস্টম পোস্ট তৈরি করার ফাংশনটা ইনিশিয়াল ভাবে এ্যাড করা হচ্ছে)
  574. *add_action ও function এর নাম <!--create_posttype-->এর বদলে যেকোন নাম ব্যবহার করা যায়।
  575. *register_post_type এ যে নাম ব্যবহার করা হবে সেটাই রেজিস্টার পোস্টের আইডি হিসাবে বিবেচিত হবে। যেমন: acme_product
  576. *'name' => __( 'portfolios' ), এই নামটা মেনুতে একটা আইটেম হিসাবে দেখানো হবে।
  577. *'singular_name' => __( 'Portfolio' ) হবে
  578. *'rewrite' => array('slug' => 'portfolio-item'),
  579. 'public' => true, এর মানে, এটা সবাই দেখতে পাবে। false হলে এটা শুধু এ্যাডমিন দেখতে পাবে।
  580. 'has_archive' => true, পোস্টের আর্কাইভ সিস্টেম দেখতে হলে এটা true থাকতে হবে।
  581. 'add_new_item' => __( 'Add New Portfolio' ) নতুন পোস্ট নেয়া হলে পোস্টের শুরুতে এটা টাইটেল হিসাবে শো করবে।
  582. 'supports' => array('author', 'thumbnail', 'title', 'editor', 'custom-fields'), সাপোর্টের মধ্যে যা যা শো করাতে চাই সেগুলো লিখতে হবে।
  583. <?php
  584.  
  585. add_action( 'init', 'create_posttype' );
  586. function create_posttype() {
  587.     register_post_type( 'acme_product',
  588.         array(
  589.             'labels' => array(
  590.                 'name' => __( 'portfolios' ),
  591.                 'singular_name' => __( 'Portfolio' )
  592.             ),
  593.             'public' => true,
  594.             'has_archive' => true,
  595.             'rewrite' => array('slug' => 'portfolio-item'),
  596.         )
  597.     );
  598. }
  599.  
  600. ?>
  601.  
  602. <!-- costom post labels (address http://codex.wordpress.org/Function_Reference/register_post_type) -->
  603.  
  604.     'name' - general name for the post type, usually plural. The same as, and overridden by $post_type_object->label
  605.     'singular_name' - name for one object of this post type. Defaults to value of name
  606.     'menu_name' - the menu name text. This string is the name to give menu items. Defaults to value of name label
  607.     'name_admin_bar' - name given for the Add New dropdown on admin bar. Defaults to singular name if it exists, name otherwise.
  608.     'all_items' - the all items text used in the menu. Default is the Name label
  609.     'add_new' - the add new text. The default is Add New for both hierarchical and non-hierarchical types. When internationalizing this string, please use a gettext context matching your post type. Example: _x('Add New', 'product');
  610.     'add_new_item' - the add new item text. Default is Add New Post/Add New Page
  611.     'edit_item' - the edit item text. Default is Edit Post/Edit Page
  612.     'new_item' - the new item text. Default is New Post/New Page
  613.     'view_item' - the view item text. Default is View Post/View Page
  614.     'search_items' - the search items text. Default is Search Posts/Search Pages
  615.     'not_found' - the not found text. Default is No posts found/No pages found
  616.     'not_found_in_trash' - the not found in trash text. Default is No posts found in Trash/No pages found in Trash
  617.     'parent_item_colon' - the parent text. This string isn't used on non-hierarchical types. In hierarchical ones the default is Parent Page
  618.  
  619. <!-- supports -->
  620.     'title'
  621.     'editor' (content)
  622.     'author'
  623.     'thumbnail' (featured image, current theme must also support post-thumbnails)
  624.     'excerpt'
  625.     'trackbacks'
  626.     'custom-fields'
  627.     'comments' (also will see comment count balloon on edit screen)
  628.     'revisions' (will store revisions)
  629.     'page-attributes' (menu order, hierarchical must be true to show Parent option)
  630.     'post-formats' add post formats
  631.  
  632. <?php
  633. add_action( 'init', 'create_posttype');
  634. function create_posttype() {
  635.     register_post_type( 'acme_product',
  636.         array(
  637.             'labels' => array(
  638.                 'name' => __( 'Products'),
  639.                 'singular_name' => __( 'Portfolio' )
  640.             ),
  641.             'public' => true,
  642.             'supports' => array('author', 'thumbnail', 'title', 'editor', 'custom-fields'),
  643.             'has_archive' => true,
  644.             'rewrite' => array('slug' => 'products'),
  645.         )
  646.     );
  647. }
  648.  
  649. ?> 
  650.  
  651.  
  652.  
  653. <!-- custom post query sample code -->
  654. <?php
  655. global $post;
  656. $args = array( 'posts_per_page' => -1, 'post_type'=> 'holistic-health');
  657. $myposts = get_posts( $args );
  658. foreach( $myposts as $post ) : setup_postdata($post); ?>
  659.  
  660. <div class="single_column">
  661.     <h4><?php the_title(); ?></h4>
  662.     <?php the_post_thumbnail('fitness-page', array('class'=> 'img-thumb')); ?>
  663.     <?php the_content(); ?>
  664.  
  665. </div>
  666. <?php endforeach; ?>
  667.  
  668.  
  669.  
  670. <!-- custom post query -->
  671.  
  672.  
  673.  
  674. <!-- Change Post permalink -->
  675.  
  676. Go to settings> Permalinks> Post name
  677.  
  678. then enable rewrite module of wamp server
  679.  
  680. Go to apache> apache modules> rewrite module> then restrat wamp server
  681.  
  682.  
  683.  
  684.  
  685. <!-- wordpress sever to server transfer -->
  686.  
  687. 2 backup >
  688.     a-wordpress all files backup to zip
  689.     b-database backup
  690.  
  691. upload all files backup to htdocs
  692.  
  693. create new database
  694.  
  695. import old database to new database (phpmyadmin)
  696.  
  697. phpmyadmin> clilck property options> site url> edit> edit domain name
  698.  
  699. edit wp config file
  700.  
  701. after install wordpress > go to wordpress dashboard> settings> url > change *wordpress address url *site address url> save change
  702.  
  703.  
  704.  
  705.  
  706. <!-- Custom taxonomy -->
  707. 2 kinds of taxonomy >catagory >tag
  708.  
  709. =====================================================================================================
  710. // Register Custom Taxonomy
  711. =====================================================================================================
  712. <?php
  713. function pages_taxonomy() {
  714.         register_taxonomy(
  715.                 'portfolio_cat',  //1. The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces). example: portfolio_cat
  716.                 'portfolio-items',                  //2. post type name  , custom post id (register_post_type id): example: news_sites
  717.                 array(
  718.                         'hierarchical'          => true,
  719.                         'label'                         => 'Portfolio Category',  //3. Display name
  720.                         'query_var'             => true,
  721.                         'rewrite'                       => array(
  722.                                 'slug'                  => 'portfolio-category', // 4. This controls the base slug that will display before each term
  723.                                 'with_front'    => false // Don't display the category base before
  724.                                 )
  725.                         )
  726.         );
  727. }
  728. add_action( 'init', 'pages_taxonomy');        
  729. ?>  
  730.  
  731. =====================================================================================================
  732.  
  733. ট্যাক্সনমি ক্যাটাগরি ব্যবহারের সুবিধা:
  734. ধরা যাক পোর্টফোলিও একটা নির্দিষ্ট বিভাগ। এই পোর্টফোলিও বিভাগের পোস্ট গুলিকে আমি দুই ধরনের ক্যাটাগরিতে ভাগ করতে চাচ্ছি। >ফিচারড্‌ >সাধারন
  735. এখন ফিচারড্‌ ক্যাটাগরির পোস্টগুলি শুধুমাত্র হোম পেজে শো করবে।
  736. এবং সাধারন ক্যাটাগরির পোস্টগুলি পোর্টফোলিও পেজে শো করবে।
  737.  
  738.  
  739. <!-- taxonomy query -->
  740. <?php
  741. global $post;
  742. $args = array( 'posts_per_page' => -1, 'post_type'=> 'portfolio-items', 'portfolio_cat' => 'Featured'); //"Featured" only featured category post will be show here
  743. $myposts = get_posts( $args );
  744. foreach( $myposts as $post ) : setup_postdata($post); ?>
  745.  
  746.  
  747. <!-- Your div -->
  748.  
  749. <?php endforeach; ?>
  750.  
  751.  
  752.  
  753. <!-- for featured image custom post -->
  754. paste this code to functions.php
  755. <?php
  756. add_theme_support( 'post-thumbnails', array( 'post' ) );
  757. add_theme_support( 'post-thumbnails', array( 'portfolio-items') ); //"portfolio-items" is custom post registered id
  758.  
  759. ?> 
  760.  
  761. <!-- for featured image crop -->
  762. <?php
  763. add_image_size( 'portfolio-thumb', 220, 105 );
  764. ?>
  765.  
  766. <!-- for featured image quary code -->
  767. <?php the_post_thumbnail('portfolio-thumb', array('class' => 'imgthumb')); ?>
  768.  
  769.  
  770. ***টপিকস্‌:
  771. কাস্টম পোস্ট থেকে কিভাবে কাস্টম ফিল্ডে ডেটা নিয়ে আসা যায়-
  772.  
  773. প্রথমত: কাস্টম পোস্টের ভিতর কাস্টম ফিল্ডের জন্য একটা ভেরিয়েবেল নিতে হবে।
  774. দ্বিতীয়ত: if endif এর ব্যবহার
  775. তৃতীয়ত: echo get_template_directory_uri() এর বদলে echo variable
  776. উদাহরন:
  777. original costom post
  778.     <?php
  779.     global $post;
  780.     $args = array( 'posts_per_page' => 4, 'post_type'=> 'portfolio-items', 'portfolio_cat' => 'Featured');
  781.     $myposts = get_posts( $args );
  782.     foreach( $myposts as $post ) : setup_postdata($post); ?>
  783.  
  784.         <div class="work span3">
  785.             <?php the_post_thumbnail('portfolio-thumb', array('class' => 'imgthumb')); ?>
  786.             <h4><?php the_title(); ?></h4>
  787.             <?php the_content(); ?>
  788.             <!-- from here (custom post to custom field data)-->
  789.             <div class="icon-awesome">
  790.                 <a href="<?php echo get_template_directory_uri(); ?>/assets/img/portfolio/work1.jpg" rel="prettyPhoto"><i class="icon-search"></i></a>
  791.                 <a href="portfolio.html"><i class="icon-link"></i></a>
  792.             </div>
  793.             <!--  to here-->
  794.         </div> 
  795.  
  796.     <?php endforeach; ?>
  797.    
  798.    
  799. উদাহরন:
  800. modified costom post
  801.  
  802.     <?php
  803.     global $post;
  804.     $args = array( 'posts_per_page' => 4, 'post_type'=> 'portfolio-items', 'portfolio_cat' => 'Featured');
  805.     $myposts = get_posts( $args );
  806.     foreach( $myposts as $post ) : setup_postdata($post); ?>
  807.  
  808. <!-- variable start-->
  809. <?php
  810.     $large_image= get_post_meta($post->ID, 'large_image', true);
  811.     $portfolio_link= get_post_meta($post->ID, 'portfolio_link', true);
  812. ?>
  813. <!-- variable end-->
  814.         <div class="work span3">
  815.             <?php the_post_thumbnail('portfolio-thumb', array('class' => 'imgthumb')); ?>
  816.             <h4><?php the_title(); ?></h4>
  817.             <?php the_content(); ?>
  818.             <div class="icon-awesome">
  819.        
  820. <!-- use of if endif -  যদি ডেটা ইনপুট করা হয় তবে এ অংশটি দেখাও; অন্যথায় এ অংশটি বাদ যাক-->    
  821.             <?php if($large_image) : ?>
  822.            
  823.                 <a href="<?php echo large_image; ?>" rel="prettyPhoto"><i class="icon-search"></i></a>
  824.                
  825.             <?php endif; ?>
  826.            
  827. <!-- use of if endif and else -  যদি ডেটা ইনপুট করা হয় তবে এ অংশটি দেখাও; অন্যথায় এ লিংকটি সিঙ্গেল পোর্টফোলিও পেজে চলে যাবে-->            
  828.             <?php if($portfolio_link) : ?>  
  829.            
  830.                 <a href="portfolio.html"><i class="icon-link"></i></a>
  831.                
  832.             <?php else : ?>
  833.                 <a href="<?php the_permalink(); ?>"><i class="icon-link"></i></a>
  834.             <?php endif; ?>                
  835.             </div>
  836.         </div> 
  837.  
  838.     <?php endforeach; ?>
  839.    
  840. <!-- End -->
  841.  
  842.  
  843. ***টপিকস্‌:
  844. option framework (Option tree)
  845.  
  846. wordpress.org থেকে option tree প্লাগিন ডাউনলোড
  847.  
  848. এরপর option tree ফোল্ডারটি থিম ফোল্ডারের ভেতর রেখে দিতে হবে। এভাবে এটি থিমের সাথে ইন্টিগ্রেট করে দিতে হবে। (প্লাগিন হিসাবে দিলে হবে না।)
  849.  
  850. এরপর এর ভেতর option tree ফোল্ডারটির ভেতর ot-loader.php ফাইল ফাংশনে ইনক্লুড করে দিতে হবে।
  851.  
  852. doc link http://goo.gl/GYJrXF
  853. <!-- Activate Option Tree (put this code into functions.php)-->
  854.  
  855. add_filter( 'ot_show_pages', '__return_false' );
  856.  
  857. add_filter( 'ot_show_new_layout', '__return_false' );
  858.  
  859. add_filter( 'ot_theme_mode', '__return_true' );
  860.  
  861. include_once( 'option-tree/ot-loader.php' );
  862.  
  863. include_once( 'includes/theme-options.php' );**
  864.    
  865.  
  866. এরপর Option tree ফোল্ডারের ভেতর Option tree>assets>theme-mode>demo-theme-options.php ফাইল কপি
  867. এরপর থিম ফোল্ডারের ভেতর  create new folder -name inc > এখানে আগের কপি ফাইলটি পেস্ট > রিনেম theme-options.php
  868. এরপর functions.php তে এটি চিনিয়ে দেয়া  **include_once( 'includes/theme-options.php' ); এটার পরিবর্তে
  869.     **include_once( 'inc/theme-options.php' );
  870.    
  871.    
  872. theme options এর settings গুলি তিনটি অংশে বিভক্ত থাকে  1-contextual_help  2-sections 3-settings
  873.  
  874. =======================================================================================
  875. ব্লগ সাইট ছাড়া কোন বিজনেস সাইট করলে index.php কে homepage হিসাবে ব্যবহার করা যাবে না। এক্ষেত্রে index.php কে welcome template বানিয়ে welcome page হিসাবে ব্যবহার করতে হবে।
  876.  
  877.  
  878. index.php কে page হিসাবে ব্যবহার:
  879.  
  880. index.php কে page হিসাবে ব্যবহার করতে হলে index কে আলাদা একটা template নিতে হবে।
  881. আর সেই template কে welcome page হিসাবে ব্যবহার করতে হবে।
  882.  
  883. এজন্য index.php কে কপি করে রিনেম করতে হবে। template-welcome.php
  884. <?php
  885.     /*Template Name: Welcome Template*/
  886.    
  887.    
  888. ?>
  889.  
  890. pages> add new page > নাম Home > Template- welcome template > publish
  891.  
  892. pages> add new page > নাম Blog > Template- Default template > publish
  893.  
  894. Settings> reading> A static page > Front page-Home & Post page-Blog
  895.  
  896.  
  897.  
  898.  
  899.  
  900. </body>
  901. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement