kalponikoronno

12/02/2015

Feb 16th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 31.91 KB | None | 0 0
  1.  
  2. Today i learned (12/2/2015)
  3.  
  4. <!--bring special class to body tag-->
  5. <?php body_class(); ?>
  6. example:
  7. <body <?php body_class(); ?>> </body>
  8.  
  9.  
  10. =====================================================================================
  11. <!--Dynamic Logo-->
  12. <a href="#">My blog</a>
  13. <a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a>
  14.  
  15.  
  16. =====================================================================================
  17. <!--Admin bar hide-->
  18. /*into functions.php*/
  19. <?php
  20. add_filter('show_admin_bar', '__return_false');
  21. ?>
  22.  
  23.  
  24. =====================================================================================
  25. front-page.php
  26.  
  27. =====================================================================================
  28. <title><?php wp_title( '|', true, 'right' ); ?> <?php bloginfo('name'); ?></title>
  29.  
  30. =====================================================================================
  31. /*
  32. For fevicon
  33. */
  34. <?php bloginfo('template_directory'); ?>
  35. <link rel="icon" href="../../favicon.ico">
  36. <link rel="shortcut icon" href="<?php bloginfo('template_directory'); ?>/images/favicon.ico">
  37.  
  38. =====================================================================================
  39. /*
  40. For footer
  41. */
  42. <p> &copy; Company 2014</p>
  43. <p> &copy; <?php bloginfo('name'); ?> <?php echo date('Y'); ?></p>
  44.  
  45. =====================================================================================
  46. /*
  47. html 5 shiv
  48. */ 
  49.  
  50. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  51. <!--[if lt IE 9]>
  52.   <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  53.   <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  54. <![endif]-->
  55.  
  56. <?php
  57.     function theme_js() {
  58.    
  59.         global $wp_scripts;
  60.         wp_register_script('html5_shiv', 'https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js', '', '', false);
  61.         wp_register_script('respond_js', 'https://oss.maxcdn.com/respond/1.4.2/respond.min.js', '', '', false);
  62.         $wp_scripts->add_data('html5_shiv', 'conditional', 'lt IE 9');
  63.         $wp_scripts->add_data('respond_js', 'conditional', 'lt IE 9');
  64.        
  65.         wp_enqueue_script('bootstrap_js', get_template_directory_uri().'/js/bootstrap.min.js', array('jquery'), '', true);
  66.        
  67.     }
  68.     add_action('wp_enqueue_scripts', 'theme_js');
  69. ?>
  70.  
  71. =====================================================================================
  72. /*
  73. Bootstrap shortcode plugin
  74. */
  75.  
  76. https://wordpress.org/plugins/bootstrap-shortcodes/
  77. =====================================================================================
  78. <!--About meta tag-->
  79. <meta name="author" content="null">
  80. <meta name="description" content="null">
  81. /*
  82. install these plugins for author and description dynamic
  83. */
  84. https://wordpress.org/plugins/google-plus-authorship/
  85. https://wordpress.org/plugins/wordpress-seo/
  86.  
  87. =====================================================================================
  88. /**/
  89. * শর্টকোডগুলি tinymce button দিয়ে কাজ করে। এখন widget এর মধ্যে শর্টকোড লিখার সময় tinymce button কোথায় পাবো? tinymce button না পেলে admin কিভাবে widget এর মধ্যে শর্টকোড লিখবে?
  90.  
  91. ans: install this plugin
  92.  
  93. https://wordpress.org/plugins/black-studio-tinymce-widget/
  94.  
  95. then "visual" editor will appear on widget
  96.  
  97.  
  98. =====================================================================================
  99.  
  100. /* for page php */
  101. <?php get_sidebar(); ?>
  102. sidebar.php
  103.  
  104. /* another sidebar for blog*/
  105. <?php get_sidebar( 'blog' ); ?>
  106. sidebar-blog.php
  107. =====================================================================================
  108. full width page
  109. page-full-width.php
  110.  
  111. <?php
  112. /*
  113. Template Name: Full Width Template
  114. */
  115. ?>
  116.  
  117. =====================================================================================
  118.  
  119. home.php is blog php
  120. page.php কে কপি এবং রিনেম করে home.php করতে হবে।
  121. তাহলে wordpress home.php কে blog.php হিসাবে শনাক্ত করবে।
  122. settings>reading>
  123. front-page> Home & post-page> blog
  124.  
  125. post-page> blog সিলেক্ট করার কারনে home.php template থেকেই blog post হবে
  126. =====================================================================================
  127.  
  128. <?php wp_title(''); ?>
  129. Example:
  130. <div class="page_header">
  131.     <h1><?php wp_title(''); ?></h1>
  132. </div>
  133.  
  134. কোন পেজের হেডার এর টাইটেল হিসাবে এটি ব্যবহৃত হবে।
  135. =====================================================================================
  136. /*
  137. the_author, the_time, the_category
  138. */
  139. By Ornob, on Wednesday, April 9th, 2014 in Featured, News No Comments
  140. <p>
  141.     By <?php the_author(); ?>
  142.     on <?php echo the_time('l, F jS, Y'); ?>
  143.     in <?php the_category( ', ' ); ?>
  144.     <a href="<?php comments_link(); ?>"><?php comments_number(); ?></a>
  145. </p>
  146. =====================================================================================
  147. /*comments_template for comments option of post comment single page underneath the post */
  148. <?php comments_template(); ?>
  149.  
  150. =====================================================================================
  151.  
  152. home.php কে কপি করে archive.php তৈরি করতে হবে।
  153.  
  154. =====================================================================================
  155.  
  156. Custom Post Type UI
  157. https://wordpress.org/plugins/custom-post-type-ui/
  158.  
  159. Advanced Custom Fields
  160. https://wordpress.org/plugins/advanced-custom-fields/
  161.  
  162. =====================================================================================
  163.  
  164. /*dynamically added row break*/
  165.  
  166. <?php $portfolio_count = $the_query->current-post + 1; ?>
  167. <?php if($portfolio_count % 4 = 0) : ?>
  168. </div><div class="row">
  169. <?php endif; ?>
  170.  
  171.  
  172. /*another*/
  173.  
  174. <?php $q = new WP_Query( array( 'posts_per_page' => 6 ) ); // Edit your query ?>
  175.  
  176. <?php if( $q->have_posts() ) : ?>
  177.  
  178.     <?php while ( $q->have_posts() ) : $q->the_post(); ?>
  179.  
  180.         <?php if( 0 === ( $q->current_post  )  % 3 ): ?>
  181.             <!--Begin Row:--> <div class="row" data-equalizer>
  182.         <?php endif; ?>
  183.  
  184.         <!--Item: -->
  185.         <div class="large-4 medium-4 columns" data-equalizer-watch>
  186.             <?php get_template_part( 'partials/loop', 'archive-grid' ); ?>
  187.         </div>
  188.  
  189.         <?php if( 0 === ( $q->current_post + 1 )  % 3  ||  ( $q->current_post + 1 ) ===  $q->post_count ): ?>
  190.             <!--End Row: --> </div>
  191.         <?php endif; ?>
  192.  
  193.     <?php endwhile; ?>
  194.     <?php wp_reset_postdata(); ?>
  195.  
  196. <?php else : ?>
  197.  
  198.     <?php get_template_part( 'partials/content', 'missing' ); ?>
  199.  
  200. <?php endif; ?>
  201.  
  202.  
  203. This should give you the following layouts with three items per row:
  204.  
  205. #posts: 1
  206. <div class="row" data-equalizer>
  207.     <div class="large-4 medium-4 columns" data-equalizer-watch>
  208.         <--Content Stuff-->
  209.     </div>
  210. </div>
  211.  
  212. #posts: 2
  213. <div class="row" data-equalizer>
  214.     <div class="large-4 medium-4 columns" data-equalizer-watch>
  215.         <--Content Stuff-->
  216.     </div>
  217.     <div class="large-4 medium-4 columns" data-equalizer-watch>
  218.         <--Content Stuff-->
  219.     </div>
  220. </div>
  221.  
  222. #posts: 3
  223. <div class="row" data-equalizer>
  224.     <div class="large-4 medium-4 columns" data-equalizer-watch>
  225.         <--Content Stuff-->
  226.     </div>
  227.     <div class="large-4 medium-4 columns" data-equalizer-watch>
  228.         <--Content Stuff-->
  229.     </div>
  230.     <div class="large-4 medium-4 columns" data-equalizer-watch>
  231.         <--Content Stuff-->
  232.     </div>
  233. </div>
  234.  
  235.  
  236.    
  237.  
  238. You can use the following built-in properties of the WP_Query() class:
  239.  
  240. WP_Query::current_post // Index of the current post, starts at 0
  241. WP_Query::found_posts  // The total number of posts found
  242. WP_Query::post_count   // The number of posts being displayed.
  243.  
  244. to make your life eaiser, instead of introducing custom counters.
  245.  
  246. Here's an example that works on my install:
  247.  
  248. <?php $q = new WP_Query( array( 'posts_per_page' => 6 ) ); // Edit your query ?>
  249.  
  250. <?php if( $q->have_posts() ) : ?>
  251.  
  252.     <?php while ( $q->have_posts() ) : $q->the_post(); ?>
  253.  
  254.         <?php if( 0 === ( $q->current_post  )  % 3 ): ?>
  255.             <!--Begin Row:--> <div class="row" data-equalizer>
  256.         <?php endif; ?>
  257.  
  258.         <!--Item: -->
  259.         <div class="large-4 medium-4 columns" data-equalizer-watch>
  260.             <?php get_template_part( 'partials/loop', 'archive-grid' ); ?>
  261.         </div>
  262.  
  263.         <?php if( 0 === ( $q->current_post + 1 )  % 3  ||  ( $q->current_post + 1 ) ===  $q->post_count ): ?>
  264.             <!--End Row: --> </div>
  265.         <?php endif; ?>
  266.  
  267.     <?php endwhile; ?>
  268.     <?php wp_reset_postdata(); ?>
  269.  
  270. <?php else : ?>
  271.  
  272.     <?php get_template_part( 'partials/content', 'missing' ); ?>
  273.  
  274. <?php endif; ?>
  275.  
  276. This should give you the following layouts with three items per row:
  277.  
  278. #posts: 1
  279. <div class="row" data-equalizer>
  280.     <div class="large-4 medium-4 columns" data-equalizer-watch>
  281.         <--Content Stuff-->
  282.     </div>
  283. </div>
  284.  
  285. #posts: 2
  286. <div class="row" data-equalizer>
  287.     <div class="large-4 medium-4 columns" data-equalizer-watch>
  288.         <--Content Stuff-->
  289.     </div>
  290.     <div class="large-4 medium-4 columns" data-equalizer-watch>
  291.         <--Content Stuff-->
  292.     </div>
  293. </div>
  294.  
  295. #posts: 3
  296. <div class="row" data-equalizer>
  297.     <div class="large-4 medium-4 columns" data-equalizer-watch>
  298.         <--Content Stuff-->
  299.     </div>
  300.     <div class="large-4 medium-4 columns" data-equalizer-watch>
  301.         <--Content Stuff-->
  302.     </div>
  303.     <div class="large-4 medium-4 columns" data-equalizer-watch>
  304.         <--Content Stuff-->
  305.     </div>
  306. </div>
  307.  
  308. and
  309.  
  310. #posts: 4
  311. <div class="row" data-equalizer>
  312.     <div class="large-4 medium-4 columns" data-equalizer-watch>
  313.         <--Content Stuff-->
  314.     </div>
  315.     <div class="large-4 medium-4 columns" data-equalizer-watch>
  316.         <--Content Stuff-->
  317.     </div>
  318.     <div class="large-4 medium-4 columns" data-equalizer-watch>
  319.         <--Content Stuff-->
  320.     </div>
  321. </div>
  322. <div class="row" data-equalizer>
  323.     <div class="large-4 medium-4 columns" data-equalizer-watch>
  324.         <--Content Stuff-->
  325.     </div>
  326. </div>
  327.  
  328.  
  329.  
  330. /*another*/
  331.  
  332.  
  333. <?php /* Template Name: Page TOP movies */ get_header(); ?>
  334. <div class="container">
  335.  
  336.         <div class="row">
  337.           <div class="col-lg-12">
  338.             <div class="page-header">
  339.               <h1 id="type">TOP filmai</h1>
  340.             </div>
  341.           </div>
  342.         </div>
  343.        
  344.        
  345.  <?php
  346.  
  347.   //Set the counter to 1
  348.   $i = 1;
  349.  
  350.   //Open the row div
  351.   echo '<div class="row"><div class="movie_list">'; ?>
  352.        
  353. <?php $custom_query = new WP_Query( array( 'posts_per_page' => 24, 'meta_key' => 'wpb_post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC'  ) );
  354. while($custom_query->have_posts()) : $custom_query->the_post(); ?>
  355.            
  356.                  <div class="col-md-2">
  357.                     <div class="well">
  358.                         <h6><a href="<?php the_permalink();?>"><?php if (strlen($post->post_title) > 35) {
  359.                         echo substr(the_title($before = '', $after = '', FALSE), 0, 25) . '...'; } else {
  360.                         the_title();
  361.                         } ?></a></h6>
  362.                         <a href="<?php the_permalink();?>"><?php the_post_thumbnail('movie-thumb', array('class' => 'img-thumbnail')); ?></a>
  363.                         <a href="<?php the_permalink();?>"><button type="button" class="btn btn-default btn-sm btn-block"><span class="glyphicon glyphicon-play"></span> Žiūrėti</button></a>
  364.                     </div>
  365.                  </div>
  366.                  <?php $i++; if($i % 6 == 0) {echo '</div></div><div class="row"><div class="movie_list">'; ?>
  367.                  <?php }  ?>
  368.     <?php  endwhile;  ?>
  369.     </div></div>
  370. <?php wp_reset_postdata(); // reset the query ?>
  371.  
  372.  
  373. <?php get_footer(); ?>
  374.  
  375.  
  376. /*another*/
  377. <div class="row">
  378.     <?php
  379.     $args = array('post_type' => 'portfolio');
  380.     $the_query = new WP_Query($args);
  381.     ?>
  382.         <?php if(have_posts()) : while( $the_query->have_posts()) : $the_query->the_post(); ?>
  383.             <div class="col-sm-3 portfolio-piece">
  384.                 <?php
  385.                     $thumbnail_id = get_post_thumbnail_id();
  386.                     $thumbnail_url = wp_get_attachment_image_src( $thumbnail_id, 'thumbnail-size', true);
  387.                 ?>     
  388.                
  389.                 <img src="<?php echo $thumbnail_url[0]; ?>" alt="<?php the_title(); ?>" />
  390.                 <h3><?php the_title(); ?></h3>
  391.             </div>
  392.            
  393.             <!--dynamic row break code after 4 post-->
  394.             <?php $portfolio_count = $the_query->current-post + 1; ?>
  395.             <?php if($portfolio_count % 4 = 0) : ?>
  396.                 </div><div class="row">
  397.                 <!--every 4 posts close div and open new div with class </row>-->
  398.             <?php endif; ?>
  399.                        
  400.         <?php endwhile; endif; ?>
  401. </div>
  402.  
  403.  
  404.  
  405.  
  406. =====================================================================================
  407.  
  408. /*
  409. custom single page
  410. */
  411. default post গুলি শো হবে single.php থেকে।
  412. আর custom post গুলি শো হবে single-(custom_post).php থেকে।
  413. Example: Custom post is : "portfolio"
  414. single-portfolio.php
  415.  
  416. =====================================================================================
  417.  
  418. <?php next_posts_link('%link', 'Left'); ?>
  419. <?php previous_posts_link('%link', 'right'); ?>
  420.  
  421. all portfolio url
  422.  
  423. <span><a href="<?php bloginfo('url'); ?>/?p=68"></a></span>
  424. =====================================================================================
  425.  
  426. <?php the_field('link'); ?>
  427. <a href="<?php the_field('link'); ?>"></a>
  428. =====================================================================================
  429.  
  430. /*loop*/
  431.  
  432. <?php
  433. $args = array('post_type' = 'post', 'category_name' => 'featured');
  434. $the_query = new WP_Query($args);
  435. ?>
  436.  
  437. <?php if(have_posts()) : while($the_query->have_posts()) : $the_query->the_post(); ?>
  438.  
  439. <?php endwhile; endif; ?>
  440. =====================================================================================
  441. /*rewind post*/
  442. <?php rewind_post(); ?>
  443. =====================================================================================
  444. /*bootstrap carousel slider dynamic*/
  445.  
  446. /*Original mark up*/
  447.  
  448. <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
  449. <!-- Indicators -->
  450.     <ol class="carousel-indicators">
  451.         <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
  452.         <li data-target="#carousel-example-generic" data-slide-to="1"></li>
  453.         <li data-target="#carousel-example-generic" data-slide-to="2"></li>
  454.     </ol>
  455.  
  456. <!-- Wrapper for slides -->
  457.     <div class="carousel-inner" role="listbox">
  458.         <div class="item active">
  459.             <img src="..." alt="...">
  460.             <div class="carousel-caption">
  461.             ...
  462.             </div>
  463.         </div>
  464.         <div class="item">
  465.             <img src="..." alt="...">
  466.             <div class="carousel-caption">
  467.             ...
  468.             </div>
  469.         </div>
  470.         ...
  471.     </div>
  472.  
  473. <!-- Controls -->
  474.     <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
  475.         <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
  476.         <span class="sr-only">Previous</span>
  477.     </a>
  478.     <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
  479.         <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
  480.         <span class="sr-only">Next</span>
  481.     </a>
  482. </div>
  483.  
  484.  
  485. /*Dynamic mark up*/
  486.  
  487. /*
  488. if it is equal to 0 and if it is,
  489. it will going to display "active" class
  490.  
  491. and if it is not equal to 0 then it will not display anything
  492. */
  493. <?php
  494. $args = array('post_type' = 'post', 'category_name' => 'featured');
  495. $the_query = new WP_Query($args);
  496. ?>
  497.  
  498. <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
  499. <!-- Indicators -->
  500.     <ol class="carousel-indicators">
  501.         <?php if(have_posts()) : while($the_query->have_posts()) : $the_query->the_post(); ?>
  502.        
  503.             <li data-target="#carousel-example-generic" data-slide-to="<?php echo $the_query->current_post; ?>" class="<?php if($the_query->current_post = 0) : ?>active<?php endif; ?>"></li>
  504.            
  505.         <?php endwhile; endif; ?>
  506.     </ol>
  507.  
  508.     <?php rewind_post(); ?>
  509. <!-- Wrapper for slides -->
  510.     <div class="carousel-inner" role="listbox">
  511.    
  512.     <?php if(have_posts()) : while($the_query->have_posts()) : $the_query->the_post(); ?>
  513.    
  514.         <div class="item <?php if($the_query->current_post = 0) : ?>active<?php endif; ?>">
  515.        
  516.             <?php
  517.                 $thumbnail_id = get_post_thumbnail_id();
  518.                 $thumbnail_url = wp_get_attachment_image_src( $thumbnail_id, 'thumbnail-size', true);
  519.                 $thumbnail_meta = get_post_meta($thumbnail_id, 'wp_get_attachment_image_alt', true);
  520.             ?>     
  521.            
  522.             <img src="<?php echo $thumbnail_url[0]; ?>" alt="<?php echo $thumbnail_meta; ?>">
  523.             <div class="carousel-caption"> <?php the_title(); ?></div>
  524.         </div>
  525.        
  526.     <?php endwhile; endif; ?>  
  527.  
  528.     </div>
  529.  
  530. <!-- Controls -->
  531.     <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
  532.         <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
  533.         <span class="sr-only">Previous</span>
  534.     </a>
  535.     <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
  536.         <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
  537.         <span class="sr-only">Next</span>
  538.     </a>
  539. </div>
  540.  
  541.  
  542. =====================================================================================
  543.  
  544. /*Modal window*/
  545. /*Modal form*/
  546. /* ninja forms plugin */
  547. =====================================================================================
  548.  
  549.  
  550. Building Websites with Bootstrap 3
  551. HTML Tables
  552. HTML Forms
  553. HTML Video and Audio
  554. New Features in CSS
  555. How to Use Google Analytics
  556. SEO Basics
  557. How to Make a Favicon
  558.  
  559.  
  560. Using PHP with MySQL
  561.  
  562.  
  563.  
  564. =====================================================================================
  565.  
  566. /*
  567. custom post query for one page theme
  568. */
  569.  
  570. <?php
  571. $args = array('post_type' => 'page', 'order' => 'ASC');
  572. $the_query = new WP_Query($args);
  573. ?>
  574.  
  575. <?php if(have_posts()) : while($the_query->have_posts()) : $the_query->the_post(); ?>
  576.         <?php get_template_part( 'content', 'page'); ?>
  577. <?php endwhile; endif; ?>
  578.  
  579.  
  580. =====================================================================================
  581. <?php get_template_part( 'content', 'page'); ?>
  582. its meaning
  583. content-page.php
  584.  
  585. <?php get_template_part( 'content'); ?>
  586. its meaning
  587. content.php
  588. =====================================================================================
  589. <?php echo $post->post_name; ?>
  590. =====================================================================================
  591.  
  592. <?php
  593. global $post;
  594.  
  595. ?>
  596. <article id="<?php echo $post->post_name; ?>">
  597.    
  598. </article><!-- #post-## -->
  599. =====================================================================================
  600. jquery scroll to
  601. =====================================================================================
  602. <script type="text/javascript">
  603. $("#button").click(function() {
  604.     $('html, body').animate({
  605.         scrollTop: $("#elementtoScrollToID").offset().top
  606.     }, 2000);
  607. });
  608. </script>
  609.  
  610.  
  611. <script type="text/javascript">
  612. ( function( $ ) {
  613.     $("nav a").click(function() {
  614. /* "nav a" বলতে কোন অংশের উপর ক্লিক করতে হবে, সেটা বোঝানো হয়েছে  */
  615.  
  616.         var link = $(this).attr('href');
  617.        
  618.         $('html, body').animate({
  619.             scrollTop: $(link).offset().top
  620. /* link বলতে কোন এলিমেন্টের উপর scrollTop কাজ করবে, সেটা বোঝানো হয়েছে    */        
  621.         }, 1000);
  622.     });
  623. } )( jQuery );
  624. </script>
  625.  
  626.  
  627. <script type="text/javascript">
  628. ( function( $ ) {
  629.     $("nav a").click(function() {
  630.         var link = $(this).attr('href');
  631.         $('html, body').animate({
  632.             scrollTop: $(link).offset().top
  633.         }, 1000);
  634.     });
  635. } )( jQuery );
  636. </script>
  637.  
  638.  
  639. =====================================================================================
  640.  
  641.  
  642.  
  643. steps--->
  644.  
  645. --> install (one_page_theme)underscores.me theme
  646.  
  647. --> add custom css
  648.  
  649. --> 4 page created : Home, Portfolio, About me, Contact
  650.  
  651. --> Front page display> static page> Home
  652.  
  653. --> copy and duplicate page.php > rename one-page-site.php
  654. /**
  655. * Template Name: One page site
  656. */
  657.  
  658.  
  659. --> /*use wp query into one page site*/
  660. <?php
  661. $args = array('post_type' => 'page', 'order' => 'ASC', 'orderby' => 'menu_order');
  662. $the_query = new WP_Query($args);
  663. ?>
  664.  
  665. <?php if(have_posts()) : while($the_query->have_posts()) : $the_query->the_post(); ?>
  666.     <?php get_template_part( 'content', 'page'); ?>
  667. <?php endwhile; endif; ?>
  668.  
  669.  
  670. -->Now all 4 page will be displayed in one page
  671.  
  672.  
  673. --><?php get_template_part( 'content', 'page'); ?> its meaning content-page.php
  674.  
  675.  
  676. -->Bring slug name as page post id
  677. use slug name to post id
  678. example:
  679. id="<?php the_ID(); ?>"
  680. /*change*/
  681. <?php
  682. global $post;
  683. ?>
  684. id="<?php echo $post->post_name; ?>"
  685.  
  686.  
  687. -->now check its working or not
  688. address+#portfolio
  689.  
  690. -->But menu navigation is not selected yet
  691. now menu need use # tag instead of url
  692. delete default menu
  693. use Links: Link text-> Home, URL-> #home
  694. here: #home is post slug name
  695.  
  696. -->Now i have to use smooth scroll for menu
  697. add theme.js and into it
  698. <script type="text/javascript">
  699. ( function( $ ) {
  700.  
  701. $("nav a").click(function() {
  702.     var link = $(this).attr('href');
  703.     $('html, body').animate({
  704.         scrollTop: $(link).offset().top
  705.     }, 1000);
  706. });
  707.  
  708. } )( jQuery );
  709. </script>
  710.  
  711.  
  712.                     <div class="single_n text-center">
  713.                         <div class="col-xs-3 col-sm-3 col-lg-2 news_area">
  714.                             <a href="'.$link.'">
  715.                               <img alt="" class="img-responsive" data-src="" src="'.$newsimage[0].'" data-holder-rendered="true">
  716.                               <h4>'.get_the_title().'</h4>
  717.                              
  718.                               </a>
  719.                         </div> 
  720.                     </div>
  721. [np_post count="" category=""]
  722. 04_02-Using custom queries to display content from different pages
  723.  
  724. কাস্টম ফিল্ডে বাটনের লিংক দিতে পারি নি, কাস্টম ফিল্ড কাজ করে না
  725. শর্টকোডে ওয়ার্ডপ্রেস ডিফল্ট পোস্টের ক্যাটাগরি আনতে পারি নি
  726. one page html theme : front page এ একটা লিংক থাকবে, ঐ লিংকটা তে গেলে অন্য একটা পেজে যাবে, এবং ঐ পেজে ঐ বিষয়ের ডিটেইলস দেখাবে, এটা করতে পারিনি
  727.  
  728. http://codex.wordpress.org/Theme_Development
  729.  
  730.  
  731.  
  732.  
  733.  
  734. 16/feb/2015
  735.  
  736. child theme
  737. original theme folder name twentyfifteen
  738. child theme foldername হবে twentyfifteen-child
  739. অবস্থান হবে original theme folder এর পাশের folder
  740. folder এর মধ্যে style.css নামে file তৈরি করতে হবে
  741. style.css এর মধ্যে লিখতে হবে
  742. /*
  743.  Theme Name:   Twenty Fifteen Child
  744.  Theme URI:    http://example.com/twenty-fifteen-child/
  745.  Description:  Twenty Fifteen Child Theme
  746.  Author:       John Doe
  747.  Author URI:   http://example.com
  748.  Template:     twentyfifteen
  749.  Version:      1.0.0
  750.  License:      GNU General Public License v2 or later
  751.  License URI:  http://www.gnu.org/licenses/gpl-2.0.html
  752.  Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
  753.  Text Domain:  twenty-fifteen-child
  754. */
  755.  
  756. যে file টি পরিবর্তন হবে সেটা  parent folder থেকে child theme folder এর মধ্যে কপি করে আনতে হবে
  757. copy header.php > then edit
  758.  
  759. functions.php কপি
  760. parent theme এর functions.php কল করতে হবে
  761. <?php
  762. require_once(get_stylesheet_directory().'/functions.php');
  763. ?>
  764.  
  765. details:
  766. http://codex.wordpress.org/Child_Themes
  767.  
  768. child theme (lander) এর style.css এর মধ্যে parent theme এর style.css import করতে হবে
  769. @import url('../simone/style.css');
  770. .. ->jump out to the lander folder
  771. /simone in to the simone folder
  772. then load style.css
  773.  
  774. এবার theme এ গিয়ে child theme active করতে হবে
  775.  
  776. one page theme এ front page হিসাবে front-page.php কে show করাতে হবে
  777.  
  778.  
  779. front-page.php এর মধ্যে 4 টি section লিখা হলো
  780.     call to action
  781.     services
  782.     meet the doctor
  783.     contact us
  784.    
  785. lander-style.css নামে একটা new file তৈরি করা হলো lander folder এর মধ্যে
  786. functions.php নামে একটা new file তৈরি করা হলো lander folder এর মধ্যে
  787. functions.php এর মধ্যে comment করা হলো
  788. /**
  789. * The functions file for the lander childe theme
  790. */
  791. front পেজের জন আলাদা style.css তৈরি করা হল, যা শুধু কন্ডিশনালি শো করবে
  792. <?php
  793. function lander_scripts() {
  794.     if( is_front_page() ) {
  795.         wp_enqueue_scripts('lander-styles', get_stylesheet-directory_uri().'/lander-style.css');
  796.     }
  797. }
  798. add_action('wp_enqueue_scripts', 'lander_scripts');
  799. ?>
  800.  
  801. এটা চেক করার জন্য inspect element> resources> frames> localhost> stylesheets> lander-style.css
  802.  
  803. .indent{max-width:1000px;margin:0 auto}
  804.  
  805. front-page.php এর মধ্যে book-an-appoinment পেজ শো করাতে চাই
  806. এজন্য front-page.php এর মধ্যে একটা কোয়ারি করতে হবে***
  807.  
  808.  
  809.    
  810. যদি এই book-an-appointment পেজ exist করে তবে এই কোয়ারি গ্রহনযোগ্য হবে, যদি exist না করে তবে হবে না
  811. এই কোয়ারি দিয়ে অন্য পেজের ডাটা ফ্রন্ট পেজে নিয়ে আসা যায়।
  812. <?php
  813. $query = new WP_query( 'pagename=book-an-appointment' );
  814. // The Loop
  815. if($query->have_posts()) {
  816.     while($query->have_posts()) {
  817.         $query->the_post();
  818.        
  819.         echo '<div class="entry-content">';
  820.             the_content();
  821.         echo '<div>';
  822.     }
  823. }
  824. wp_reset_postdata();
  825. //without reset query use, the page will continue running this query as the main query
  826. ?>
  827.  
  828.  
  829. services page এর আলাদা আলাদা services section গুলি শো করাতে হবে।
  830. অর্থাৎ services এর under এ থাকা different post শো করবে services page এ
  831. নতুন একটা ভেরিয়েবেল তৈরি করতে হবে services_id যা দিয়ে queried_object এর id পাওয়া যাবে
  832.  
  833. <?php
  834. $query = new WP_query( 'pagename=book-an-appointment' );
  835. $services_id = $query->queried_object->ID;
  836. // The Loop
  837. if($query->have_posts()) {
  838.     while($query->have_posts()) {
  839.         $query->the_post();
  840.        
  841.         echo '<div class="entry-content">';
  842.             the_content();
  843.         echo '<div>';
  844.     }
  845. }
  846. wp_reset_postdata();
  847.  
  848. // আরেকটা কোয়ারি তৈরি করতে হবে আলাদা আলাদা services section শো করার জন্য
  849. $args = array('post_type' => 'page', 'post_parent' => $services_id);
  850.  
  851. $services_query = new WP_query( $args );
  852. //The Loop
  853. if($services_query->have_posts()) {
  854.         echo '<ul class="services_list">';
  855.             while($services_query->have_posts()) {
  856.                 $services_query->the_posts();
  857.                 echo '<li class="clear">';
  858.                 echo '<a href="'.get_permalink().'" title="Learn more about '.get_the_title().'">';
  859.                 echo '<h3 class="service-title">'.get_the_title().' </h3>';
  860.                 echo '</a>';
  861.                 echo '<div class="services-lede">';
  862.                 the_content();
  863.                 echo '</div>';
  864.                 echo '</li>';
  865.             }  
  866.         echo '<ul>';
  867. }
  868. wp_reset_postdata();
  869. ?>
  870.  
  871.  
  872.  
  873. /*Testimonial*/
  874. /*Testimonial query*/
  875.  
  876. <?php
  877. $args = array('posts_per_page' => 3, 'orderby' => 'rand', 'category_name' => 'testimonials');
  878. $query = new WP_query( $args );
  879.  
  880. if($query->have_posts()) {
  881.     echo '<ul class="testimonials">';
  882.         while($query->have_posts()) {
  883.             $query->the_post();
  884.             echo '<li class="clear">';
  885.             echo '<figure class="testimonial-thumb">';
  886.             the_post_thumbnail('testimonial-thumb');
  887.             echo '<h3 class="testimonial-name">'.get_the_title().'</h3>';
  888.             the_content();
  889.             echo '</figure>';
  890.             echo '</li>';
  891.         }
  892.     echo '<ul>';
  893. }
  894. wp_reset_postdata();
  895. ?>
  896.  
  897.  
  898. /*
  899. default post থেকে testimonial post, and post category is testimonial
  900. front page is home page, post page is news page
  901. news পেজে গেলে testimonial post গুলি শো করে
  902. index.php বা ব্লগ থেকে testimonial category exclude করতে হবে
  903. */
  904.  
  905. /*
  906. more tag use
  907. */
  908.  
  909.  
  910. /*
  911. Adding a custom menu to the front page
  912. if we are in front page we will see custom menu
  913. and if we are any other page we will see default menu
  914. */
  915.  
  916.  
  917. <?php
  918. if( is_front_page() ) {
  919. /*custom menu*/
  920. wp_nav_menu(array('menu' => 'Front Page Menu'));
  921. } else {
  922. /*default menu*/
  923. wp_nav_menu(array('theme_location' => 'primary'));
  924. }
  925.  
  926. ?>
  927.  
  928. /*
  929. Creating menu items for page scrolling
  930. */
  931.  
  932. Adding Smooth Scroll for the scrolling effect
  933.  
  934.  
  935.  
  936.  
  937. Blogging for Your Business (Morten Rand-Hendriksen, 2013)
  938. Create an Online Portfolio with WordPress (Morten Rand-Hendriksen, 2011)
  939. Creating a Marquee in WordPress with jQuery (Chris Converse, 2014)
  940. Creating a Photo Gallery in WordPress with jQuery (Chris Converse, 2014)
  941.  
  942. Dreamweaver and WordPress. Building Mobile Sites (Joseph Lowery, 2012)
  943. Dreamweaver and WordPress. Building Sites (Joseph Lowery, 2012)
  944. Dreamweaver and WordPress. Building Themes (Joseph Lowery, 2012)
  945. Dreamweaver and WordPress. Core Concepts (Joseph Lowery, 2012)
  946. Dreamweaver CC and WordPress 3.8. Core Concepts (Joseph Lowery, 2014)
  947. Dreamweaver CS6 and WordPress 3.8. Core Concepts (Joseph Lowery, 2014)
  948.  
  949. Installing and Running WordPress. BitNami (Morten Rand-Hendriksen, 2013)
  950. Installing and Running WordPress. DesktopServer (Morten Rand-Hendriksen, 2014)
  951. Installing and Running WordPress. MAMP (Morten Rand-Hendriksen, 2013)
  952. Installing and Running WordPress. Shared Hosting (Morten Rand-Hendriksen, 2013)
  953. Installing and Running WordPress. WAMP (Morten Rand-Hendriksen, 2013)
  954. Installing and Running WordPress. WebMatrix (Morten Rand-Hendriksen, 2013)
  955.  
  956. Start with a Theme. Creative Portfolios in WordPress (Morten Rand-Hendriksen, 2012)
  957. Start with a Theme. Food Blogs in WordPress (Morten Rand-Hendriksen, 2013)
  958. Start with a Theme. Magazine Styles in WordPress (Morten Rand-Hendriksen, 2012)
  959.  
  960. WordPress. Building Responsive Themes (Morten Rand-Hendriksen, 2012)
  961. WordPress.com. Essential Training (Morten Rand-Hendriksen, 2013)
  962. WordPress. Creating Custom Widgets and Plugins with PHP (Drew Falkman, 2010)
  963. WordPress. Custom Post Types and Taxonomies (Morten Rand-Hendriksen, 2014)
  964. WordPress. Essential Training (Morten Rand-Hendriksen, 2014)
  965. WordPress. Mobile Solutions (Rand-Hendriksen, 2012)
  966. WordPress 3.8. New Features (Morten Rand-Hendriksen, 2013)
  967. WordPress 3. Building Child Themes (Morten Rand-Hendriksen, 2012)
  968. WordPress 3. Creating and Editing Custom Themes (Chris Coyier, 2010)
  969. WordPress 3. Developing Secure Sites (Jeff Starr, 2011)
  970. WordPress Developer Tips. Deleting Spam Comments in the Database (Morten Rand-Hendriksen, 2014)
  971.  
  972. WordPress Ecommerce. Core Concepts (Morten Rand-Hendriksen, 2013)
  973. WordPress Ecommerce. Easy Digital Downloads (Morten Rand-Hendriksen, 2013)
  974. WordPress Ecommerce. Integrating Shopify (Morten Rand-Hendriksen, 2014)
  975. WordPress Ecommerce. WooCommerce (Morten Rand-Hendriksen, 2013)
  976.  
  977. WordPress Plugins. Analytics (Morten Rand-Hendriksen, 2014)
  978. WordPress Plugins. Backing Up Your Site (Morten Rand-Hendriksen, 2014)
  979. WordPress Plugins. Contact Forms (Morten Rand-Hendriksen, 2014)
  980. WordPress Plugins. SEO (Morten Rand-Hendriksen, 2013)
  981. WordPress Quick Tips. Migration and Database Reset (Morten Rand-Hendriksen, 2013)
  982.  
  983.  
  984. <?php
  985. $args = array('post_type' => 'page', 'order' => 'ASC');
  986. $the_query = new WP_Query($args);
  987. ?>
  988.  
  989. <?php if(have_posts()) : while($the_query->have_posts()) : $the_query->the_post(); ?>
  990.         <?php get_template_part( 'content', 'page'); ?>
  991. <?php endwhile; endif; ?>
  992. ===================
  993. <?php
  994. $query = new WP_query( 'pagename=book-an-appointment' );
  995. $services_id = $query->queried_object->ID;
  996. // The Loop
  997. if($query->have_posts()) {
  998.     while($query->have_posts()) {
  999.         $query->the_post();
  1000.        
  1001.         echo '<div class="entry-content">';
  1002.             the_content();
  1003.         echo '<div>';
  1004.     }
  1005. }
  1006. wp_reset_postdata();
  1007. ?>
Advertisement
Add Comment
Please, Sign In to add comment