Changeset 2185342
- Timestamp:
- 11/04/2019 02:08:00 AM (5 years ago)
- Location:
- list-custom-post-with-featured-image/trunk
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
list-custom-post-with-featured-image/trunk/list-cp-featured-image.php
r1699765 r2185342 6 6 Author: Vikas Sharma 7 7 Author URI: https://profiles.wordpress.org/devikas301 8 Version: 1. 08 Version: 1.1 9 9 License: GPLv2 10 10 */ … … 17 17 function lcpfi_listpost( $lcpfi_atts ){ 18 18 19 global $post, $wpdb; 20 21 $lcpfi_args = shortcode_atts( array( 19 global $post, $wpdb; 20 $lcpfi_args = shortcode_atts(array( 22 21 'post_type' => 'post', 23 'limit' => 24 'order' => 'DESC'25 ), $lcpfi_atts ); 26 27 22 'limit' => '5', 23 'order' => 'DESC', 24 'pagination'=> 'on' 25 ), $lcpfi_atts); 26 28 27 $lcpfi_pggp = explode('/page/', $_SERVER['REQUEST_URI']); 29 28 30 29 if(isset($lcpfi_pggp[1])){ 31 30 $lcpfi_pggpcount = explode('/', $lcpfi_pggp[1]); 32 $lcpfi_gvpage = $lcpfi_pggpcount[0]; 33 34 } else { 35 36 $lcpfi_gvpage = 1; 37 31 $lcpfi_gvpage = $lcpfi_pggpcount[0]; 32 } else { 33 $lcpfi_gvpage = 1; 38 34 } 39 35 40 $lcpfi_paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : ( ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1);36 $lcpfi_paged = (get_query_var('paged')) ? get_query_var('paged') : ((get_query_var('page')) ? get_query_var('page') : 1); 41 37 42 38 $lcpfi_postargs = array( 43 'post_type' 44 'post_status' 45 'posts_per_page' 46 'paged' 47 'order' 48 'page' 39 'post_type' => $lcpfi_args['post_type'], 40 'post_status' => 'publish', 41 'posts_per_page'=> $lcpfi_args['limit'], 42 'paged' => $lcpfi_paged, 43 'order' => $lcpfi_args['order'], 44 'page' => $lcpfi_paged 49 45 ); 50 46 //'offset' => 0, 51 47 52 $lcpfi_gp = new WP_Query( $lcpfi_postargs);48 $lcpfi_gp = new WP_Query($lcpfi_postargs); 53 49 54 if ( $lcpfi_gp->have_posts() ):50 if($lcpfi_gp->have_posts()): 55 51 56 52 $lcpfi_size = 'medium'; 57 $lcpfi_gpost = '<div class="lcpfi-post-gallery"><div class="row">'; 58 53 $lcpfi_gpost = '<div class="lcpfi-post-gallery"><div class="row">'; 59 54 60 while ( $lcpfi_gp->have_posts()) : $lcpfi_gp->the_post();55 while($lcpfi_gp->have_posts()) : $lcpfi_gp->the_post(); 61 56 62 $lcpfi_pid = get_the_ID();57 $lcpfi_pid = get_the_ID(); 63 58 64 if ( has_post_thumbnail( $lcpfi_pid ) ) { 65 66 $lcpfi_pimage = get_the_post_thumbnail( $lcpfi_pid, $lcpfi_size ); 67 68 } else { 69 70 $lcpfi_pimage = '<img src="'.LCPFI_LINK.'images/default-placeholder.png" alt="'.get_the_title().'" class="default-image attachment-medium size-medium wp-post-image" style="width:284px">'; 71 59 if(has_post_thumbnail($lcpfi_pid)){ 60 $lcpfi_pimage = get_the_post_thumbnail($lcpfi_pid, $lcpfi_size); 61 } else { 62 $lcpfi_pimage = '<img src="'.LCPFI_LINK.'images/default-placeholder.png" alt="'.get_the_title().'" class="default-image attachment-medium size-medium wp-post-image" style="width:284px">'; 72 63 } 73 64 … … 77 68 78 69 $lcpfi_gpost .= '</div>'; 79 80 if (function_exists(lcpfi_pagination)){70 if($lcpfi_args['pagination'] == 'on'){ 71 if(function_exists(lcpfi_pagination)){ 81 72 $lcpfi_gpost .= '<div class="clear lcpfi-pagination-section">'.lcpfi_pagination($lcpfi_gp->max_num_pages,"",$lcpfi_paged).'</div>'; 82 73 } 83 74 } 84 75 $lcpfi_gpost .= '</div>'; 85 76 … … 91 82 add_shortcode('LCPOSTLIST', 'lcpfi_listpost'); 92 83 93 function lcpfi_pagination($numpages = '', $pagerange = '', $paged='') { 94 95 if (empty($pagerange)) { 84 function lcpfi_pagination($numpages='', $pagerange='', $paged=''){ 85 if(empty($pagerange)){ 96 86 $pagerange = 2; 97 87 } 98 88 99 if (empty($paged)){89 if(empty($paged)){ 100 90 global $paged; 101 91 $paged = 1; 102 92 } 103 if ($numpages == ''){93 if($numpages == ''){ 104 94 global $wp_query; 105 95 $numpages = $wp_query->max_num_pages; 106 if(!$numpages) 96 if(!$numpages){ 107 97 $numpages = 1; 108 98 } … … 114 104 */ 115 105 $pagination_args = array( 116 'base' => get_pagenum_link(1) .'%_%',117 'format' 118 'total' 119 'current' 120 'show_all' 121 'end_size' 122 'mid_size' 123 'prev_next' 124 'prev_text' 125 'next_text' 126 'type' 127 'add_args' 128 'add_fragment' 106 'base' => get_pagenum_link(1).'%_%', 107 'format' => 'page/%#%', 108 'total' => $numpages, 109 'current' => $paged, 110 'show_all' => False, 111 'end_size' => 1, 112 'mid_size' => $pagerange, 113 'prev_next' => True, 114 'prev_text' => __('«'), 115 'next_text' => __('»'), 116 'type' => 'plain', 117 'add_args' => false, 118 'add_fragment' => '' 129 119 ); 130 120 131 121 $lcpfi_paginate_links = paginate_links($pagination_args); 132 122 133 if ($lcpfi_paginate_links){123 if($lcpfi_paginate_links){ 134 124 $lcpfi_pgdata = "<nav class='lcpfi-glpagination'>"; 135 125 // echo "<span class='page-numbers page-num'>Page " . $paged . " of " . $numpages . "</span> "; … … 138 128 return $lcpfi_pgdata; 139 129 } 140 141 130 } 142 131 143 132 add_action( 'wp_enqueue_scripts', 'lcpfi_enqueue_styles' ); 144 function lcpfi_enqueue_styles() { 145 global $wp_styles; 146 wp_register_style('LCPFI', LCPFI_LINK. "css/lcpfi_style.css"); 147 148 wp_enqueue_style('LCPFI'); 133 function lcpfi_enqueue_styles(){ 134 global $wp_styles; 135 wp_register_style('LCPFI', LCPFI_LINK. "css/lcpfi_style.css"); 136 wp_enqueue_style('LCPFI'); 149 137 } 150 138 ?> -
list-custom-post-with-featured-image/trunk/readme.txt
r1699794 r2185342 1 1 === List Custom Post with featured image === 2 Contributors: 3 Tags: 4 Requires at least: 5 Tested up to: 4.86 Stable tag: 1.07 License: 8 License URI: 2 Contributors: devikas301 3 Tags: custom post grid, rockon, custom post list, shortcode, pagination, post, post image, title, vs 4 Requires at least: 3.6 5 Tested up to: 5.2 6 Stable tag: 1.1 7 License: GPLv2 or later 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 9 10 10 Simple plugin. Show feature image, title with pagination on anywhere using shortcode. … … 32 32 == Shortcode == 33 33 34 <code> [LCPOSTLIST post_type="post" limit=4 order="ASC" ] </code>34 <code> [LCPOSTLIST post_type="post" limit=4 order="ASC" pagination="off"] </code>
Note: See TracChangeset
for help on using the changeset viewer.