kalponikoronno

Shortcode content

Jan 5th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.60 KB | None | 0 0
  1. <?php
  2.  
  3. /*********
  4. image link or featured image
  5. **********/
  6.  
  7. $image_id = get_post_thumbnail_id();
  8. $image_url = wp_get_attachment_image_src($image_id,'thumbimage');
  9. $image_thmb = $image_url[0];
  10.  
  11. '.$image_thmb.'
  12.  
  13. /*
  14. example:
  15. <img src="'.$image_thmb.'" alt="">
  16. */
  17. =============================================================================
  18.  
  19. /*********
  20. title
  21. **********/
  22. '.get_the_title().'
  23.  
  24. /*
  25. example:
  26. <h3>'.get_the_title().'</h3>
  27. */
  28.  
  29. =============================================================================
  30. /*********
  31. content
  32. **********/
  33. '.get_the_content().'
  34. /*
  35. example:
  36. <p>'.get_the_content().'</p>
  37. */
  38. =============================================================================
  39.  
  40. /*********
  41. excerpt
  42. **********/
  43. '.get_the_excerpt().'
  44. /*
  45. example:
  46. <p>'.get_the_excerpt().'</p>
  47. */
  48. =============================================================================
  49. /*********
  50. permalink
  51. **********/
  52. '.get_permalink().'
  53. /*
  54. example:
  55. <p>'.get_the_excerpt().'</p>
  56. */
  57. =============================================================================
  58.  
  59. /*********
  60. id
  61. <?php the_ID(); ?>
  62. **********/
  63. '.get_the_ID().'
  64.  
  65. /*
  66. example:
  67. <div id="image-modal'.get_the_ID().'" class="mfp-hide modal-box">
  68. */
  69.  
  70. =============================================================================
  71. /*********
  72. image link
  73. **********/
  74.  
  75. $mixlargeimage = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'mlimage');
  76. /*
  77. example:
  78. $mixlargeimage = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'mlimage');
  79. <img src="'.$mixlargeimage[0].'" alt="">
  80. */
  81.  
  82. =============================================================================
  83. /*********
  84. custom field
  85. **********/
  86.  
  87. $idd = get_the_ID();
  88. $edic = get_post_meta($idd, 'edic', true);
  89.  
  90. '.$edic.'
  91.  
  92. /*
  93. example:
  94. <i class="fa fa-'.$edic.' eduicon"></i>
  95. */
  96.  
  97. =============================================================================
  98.  
  99. /*********
  100. shortcode into shortcode
  101. **********/
  102. '.do_shortcode($content).'
  103.  
  104. /*
  105. example:
  106. <ul class="resumeList"> <li><h3>'.$title.'</h3></li>'.do_shortcode($content).'</ul>
  107. */
  108.  
  109.  
  110. =============================================================================
  111. /*********
  112. if else elseif into shortcode
  113. **********/
  114.  
  115. extract( shortcode_atts( array(
  116.     'icon' => '',
  117. ), $atts ) );
  118.  
  119.  
  120. if($icon) :
  121.     $list .='<i class="fa fa-'.$icon.' staticon"></i> ';
  122. elseif($amount) :
  123.     $list .='<h3 class="statamnt">'.$amount.'</h3> ';
  124. else :
  125.     $list .=' ';
  126. endif;
  127.  
  128.  
  129. =============================================================================
  130. /*********
  131. for get post thumbnail
  132. **********/
  133.  
  134.  
  135. '.get_the_post_thumbnail().'
  136.  
  137.  
  138. =============================================================================
  139.  
  140.  
  141. ছোট্ট একটা টিপস
  142. =========================
  143.  
  144. শর্টকোডে কাস্টম পোস্ট নেওয়ার সময় get_the_content() ফাংশনকে কল করলে p ট‍্যাগ জেনারেট হয় না, কিন্তু যদি p ট‍্যাগ জেনারেট করতে চাই, তাহলে যেটা করতে হবে:
  145.  
  146. প্রথমে get_the_content() ফাংশনকে ভেরিয়েবলে নিতে হবে
  147.  
  148. $my_p_tag = get_the_content();
  149.  
  150. তারপর যেখানে কনটেন্ট নিব, সেখানে ব‍্যবহার করতে হবে
  151.  
  152. wpautop( $my_p_tag );
  153.  
  154. তাহলে auto p ট‍্যাগ জেনারেট হবে। বিস্তারিত: http://codex.wordpress.org/Function_Reference/wpautop
  155. ?>
Advertisement
Add Comment
Please, Sign In to add comment