Advertisement
webrur

Class 9

Apr 25th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. <?php
  2.  
  3. function factorian_page_list( $atts, $content = null ){
  4.  
  5. extract(shortcode_atts(array(
  6. 'posttype' => '',
  7. 'count' => '',
  8. 'color' => '#222222',
  9. 'icon' => '',
  10.  
  11. ), $atts));
  12.  
  13. $q = new WP_Query(array(
  14. 'post_type' => $posttype,
  15. 'posts_per_page' => $count,
  16. 'order' => '',
  17. 'orderby' => '',
  18. ));
  19.  
  20. $list = '<div class="custom_post_list"> ';
  21.  
  22. while($q->have_posts()) : $q->the_post();
  23. $idd = get_the_ID;
  24. $custom_field = get_post_meta($idd, 'custom_field', true);
  25. $post_content = get_the_content();
  26.  
  27. $list .= '<ul>';
  28. $list .= '<li><a href="'.get_permalink().'" style="color:'.$color.'">';
  29.  
  30. if(!empty ($icon)){
  31. $list .= '<i class="'.$icon.'"></i>';
  32. }
  33.  
  34. $list .= ''.get_the_title().'</a></li>';
  35. $list .= '</ul>';
  36.  
  37. endwhile;
  38.  
  39. $list .= '</div>';
  40.  
  41. return $list;
  42.  
  43. }
  44. add_shortcode('factorian_pagelist', 'seo_page_list');
  45.  
  46. function factorian_vc_pagelist_addon(){
  47.  
  48. vc_map(array(
  49.  
  50. 'name' => esc_html__('Page List', 'factorian'),
  51. 'base' => 'factorian_pagelist',
  52. 'category' => esc_html__('Factorian', 'factorian'),
  53. 'params' => array(
  54. array(
  55. 'heading' => esc_html__('Post Type', 'factorian'),
  56. 'param_name' => 'posttype',
  57. 'type' => 'textfield',
  58. 'value' => esc_html__('post', 'factorian'),
  59. 'description' => esc_html__('', 'factorian')
  60. ),
  61. array(
  62. 'heading' => esc_html__('Post Count', 'factorian'),
  63. 'param_name' => 'count',
  64. 'type' => 'textfield',
  65. 'value' => esc_html__('-1', 'factorian'),
  66. 'description' => esc_html__('', 'factorian')
  67. ),
  68. array(
  69. 'heading' => esc_html__('Link Color', 'factorian'),
  70. 'param_name' => 'color',
  71. 'type' => 'colorpicker',
  72. 'value' => esc_html__('#333', 'factorian'),
  73. 'description' => esc_html__('Select link color', 'factorian')
  74. ),
  75. array(
  76. 'heading' => esc_html__('Icon Picker', 'factorian'),
  77. 'param_name' => 'icon',
  78. 'type' => 'iconpicker',
  79. 'description' => esc_html__('Select icon', 'factorian')
  80. ),
  81. )
  82.  
  83. ));
  84.  
  85. }
  86. add_action('vc_before_init', 'factorian_vc_pagelist_addon');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement