Changeset 2489374
- Timestamp:
- 03/08/2021 10:09:43 AM (5 years ago)
- Location:
- load-more-posts/trunk
- Files:
-
- 4 edited
-
css/custom.css (modified) (1 diff)
-
js/custom.js (modified) (3 diffs)
-
loadmorepost.php (modified) (10 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
load-more-posts/trunk/css/custom.css
r2478697 r2489374 134 134 .news-block-thumb img {width: 100%;} 135 135 .wp_all_posts_section {width:100% !important;} 136 .news-block-meta.entry-meta img.wp_icons {max-width: 16px;margin-right: 5px; }136 .news-block-meta.entry-meta img.wp_icons {max-width: 16px;margin-right: 5px;display: inline;} 137 137 .wp_post_items h3 {font-size: 25px;} 138 138 .wp_post_items h3 a {color: #333;} -
load-more-posts/trunk/js/custom.js
r2481384 r2489374 1 1 //custom js 2 2 jQuery(document).ready(function(){ 3 4 3 // Load more data 5 jQuery('.wp_load-more'). click(function(){4 jQuery('.wp_load-more').on("click",function(){ 6 5 var wp_page_posts = Number(jQuery('#wp_page_posts').val()); 7 6 var wp_post_show = Number(jQuery('#wp_post_show').val()); … … 9 8 var wp_post_show1 = Number (wp_post_show + wp_page_posts); 10 9 var cat_id = jQuery('#wp_cat_id').val(); 10 var post_type = jQuery('#wp_posType').val(); 11 11 if(wp_post_show1 > allcount){ 12 12 var limit_to = Number(allcount - wp_post_show); … … 24 24 dataType: "html", 25 25 data: { 26 action: "get_new_data_items",from_limit:wp_post_show,limit_to:limit_to,cat_id:cat_id 26 action: "get_new_data_items",from_limit:wp_post_show,limit_to:limit_to,cat_id:cat_id,post_type:post_type 27 27 }, 28 28 beforeSend:function(){ -
load-more-posts/trunk/loadmorepost.php
r2486423 r2489374 6 6 * Version: 1.2.0 7 7 * Author: Rajeev Chauhan 8 * Author URI: mailto:rajeev.glocify@gmail.com 8 9 * Text Domain: loadmorepost 9 10 * Domain Path: /lang … … 41 42 } 42 43 function wp_add_css_and_scripts() { 43 wp_register_style( 'wp_loadmore_css', plugins_url('css/custom.css',__FILE__ ),array(), "1.3. 2");44 wp_register_style( 'wp_loadmore_css', plugins_url('css/custom.css',__FILE__ ),array(), "1.3.3"); 44 45 wp_enqueue_style( 'wp_loadmore_css' ); 45 46 wp_register_script( 'wp_loadmore_js', plugins_url('js/custom.js',__FILE__ ), array( 'jquery' ), "1.2.2"); … … 51 52 'hide_btn_Txt' => get_option('wp_hide_btn_Txt','Load Less'), 52 53 'load_less_btn' => get_option('wp_load_less_Btn','0'), 53 );54 ); 54 55 wp_localize_script( 'wp_loadmore_js', 'loadMoreJS', $translation_array ); 55 56 wp_enqueue_script( 'wp_loadmore_js'); … … 70 71 function wp_load_more_option($atts){ 71 72 $atts = shortcode_atts( 72 array('cat_id' => false ),73 array('cat_id' => false,'post_type' => false), 73 74 $atts 74 ); 75 ); 76 $post_type = $atts['post_type']; 75 77 $cat_ID = $atts['cat_id']; 76 78 $rowperpage = get_option('wp_post_per_page'); 77 79 if($rowperpage<=0){$rowperpage=10;} 78 if(!empty($cat_ID)){ 80 if(post_type_exists( $post_type )){ 81 $post_type = $atts['post_type']; 82 }else{$post_type ='';} 83 if((!empty($post_type)) && (!empty($cat_ID))){ 84 $the_query = new WP_Query( 'cat='.$cat_ID && 'post_type='.$post_type ); 85 $allcount = $the_query->found_posts; 86 }elseif(!empty($post_type)){ 87 $the_query = new WP_Query( 'post_type='.$post_type ); 88 $allcount = $the_query->found_posts; 89 }elseif(!empty($cat_ID)){ 79 90 $the_query = new WP_Query( 'cat='.$cat_ID ); 80 91 $allcount = $the_query->found_posts; … … 82 93 $allcount = wp_count_posts('post')->publish; 83 94 } 95 if(empty($post_type)){$post_type = 'post';} 84 96 $html =''; 85 97 if($allcount>0): … … 90 102 'orderby' => 'date', 91 103 'order' => 'DESC', 92 'post_type' => 'post',104 'post_type' => $post_type, 93 105 'post_status' => 'publish' 94 106 ); … … 102 114 $html .= '<style>.wp_all_posts_section {display: grid;grid-template-columns: auto auto auto auto;grid-gap: 16px;} .news-block-thumb img {height: 225px;object-fit: cover;} @media screen and (min-width : 100px) and (max-width : 667px){.wp_all_posts_section {grid-template-columns: auto;}}</style>'; 103 115 }else{ 104 116 $html .= '<style>.wp_all_posts_section {display: grid;grid-template-columns:auto;grid-gap: 16px;}.news-block-thumb img {max-height: 500px;object-fit: cover;} @media screen and (min-width : 100px) and (max-width : 667px){.wp_all_posts_section {grid-template-columns: auto;}}</style>'; 105 117 } 106 118 foreach($results as $result){ … … 160 172 <input type="hidden" id="wp_post_show" value="'.$rowperpage.'"> 161 173 <input type="hidden" id="wp_all" value="'. $allcount .'"> 174 <input type="hidden" id="wp_posType" value="'. $post_type .'"> 162 175 <input type="hidden" id="wp_cat_id" value="'. $cat_ID .'"></div>'; 163 176 endif; … … 172 185 $limit_to = sanitize_text_field($_POST['limit_to']); 173 186 $cat_id = sanitize_text_field($_POST['cat_id']); 187 $post_type = sanitize_text_field($_POST['post_type']); 174 188 $args = array( 175 189 'numberposts' => $limit_to, … … 178 192 'orderby' => 'date', 179 193 'order' => 'DESC', 180 'post_type' => 'post',194 'post_type' => $post_type, 181 195 'post_status' => 'publish' 182 196 ); -
load-more-posts/trunk/readme.txt
r2486427 r2489374 26 26 * Any Category: [wp_load_more_option cat_id="1"] -- Where 1 is category id. 27 27 * Multiple Categories: [wp_load_more_option cat_id="1,3"] -- Where 1 and 3 are category id. 28 * Custom Posts: [wp_load_more_option post_type="custom_post_type"] -- Where "custom_post_type" is the post type, If the post type is wrong then all the posts will be show. 28 29 29 30 == Changelog == … … 48 49 3. How can I show all posts for multiple categories? 49 50 Use shortcode for any page [wp_load_more_option cat_id="1,3"] ***Where 1 and 3 are category id*** 51 52 4. How can I show all posts for Custom Posts? 53 Use shortcode for any page [wp_load_more_option post_type="custom_post_type"] ***Where "custom_post_type" is the post type, If the post type is wrong then all the posts will be show.*** 50 54 51 55 == Upgrade Notice ==
Note: See TracChangeset
for help on using the changeset viewer.