Plugin Directory

Changeset 2185342


Ignore:
Timestamp:
11/04/2019 02:08:00 AM (5 years ago)
Author:
devikas301
Message:

new version. Added new pagination show/hide feature & tested with latest WP version

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  
    66Author: Vikas Sharma
    77Author URI: https://profiles.wordpress.org/devikas301
    8 Version: 1.0
     8Version: 1.1
    99License: GPLv2
    1010*/
     
    1717  function lcpfi_listpost( $lcpfi_atts ){
    1818     
    19     global $post, $wpdb;
    20    
    21     $lcpfi_args = shortcode_atts( array(
     19    global $post, $wpdb;   
     20    $lcpfi_args = shortcode_atts(array(
    2221        'post_type' => 'post',
    23         'limit'     =>  '5', 
    24         'order'     =>  'DESC'
    25     ), $lcpfi_atts );   
    26        
    27       
     22        'limit'     => '5', 
     23        'order'     => 'DESC',
     24        'pagination'=> 'on'
     25       ), $lcpfi_atts);    
     26     
    2827     $lcpfi_pggp = explode('/page/', $_SERVER['REQUEST_URI']);
    2928     
    3029     if(isset($lcpfi_pggp[1])){
    3130        $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;   
    3834     }
    3935     
    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);
    4137     
    4238    $lcpfi_postargs = array(
    43             'post_type'      => $lcpfi_args['post_type'],
    44             'post_status'    => 'publish',       
    45             'posts_per_page' => $lcpfi_args['limit'],
    46             'paged'          => $lcpfi_paged,           
    47             'order'          => $lcpfi_args['order'],   
    48             'page'           => $lcpfi_paged
     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
    4945      );
    5046      //'offset'         => 0,     
    5147     
    52     $lcpfi_gp = new WP_Query( $lcpfi_postargs );
     48    $lcpfi_gp = new WP_Query($lcpfi_postargs);
    5349   
    54     if ( $lcpfi_gp->have_posts() ) :
     50    if($lcpfi_gp->have_posts()):
    5551       
    5652     $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">';
    5954   
    60      while ( $lcpfi_gp->have_posts() ) : $lcpfi_gp->the_post();   
     55     while($lcpfi_gp->have_posts()) : $lcpfi_gp->the_post();     
    6156     
    62       $lcpfi_pid = get_the_ID();     
     57       $lcpfi_pid = get_the_ID();   
    6358     
    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">';           
    7263      }       
    7364     
     
    7768     
    7869     $lcpfi_gpost .= '</div>';
    79      
    80       if (function_exists(lcpfi_pagination)) {
     70     if($lcpfi_args['pagination'] == 'on'){
     71      if(function_exists(lcpfi_pagination)){
    8172       $lcpfi_gpost .= '<div class="clear lcpfi-pagination-section">'.lcpfi_pagination($lcpfi_gp->max_num_pages,"",$lcpfi_paged).'</div>';
    8273      } 
    83       
     74     }
    8475     $lcpfi_gpost .= '</div>'; 
    8576     
     
    9182 add_shortcode('LCPOSTLIST', 'lcpfi_listpost');     
    9283 
    93  function lcpfi_pagination($numpages = '', $pagerange = '', $paged='') {
    94 
    95   if (empty($pagerange)) {
     84 function lcpfi_pagination($numpages='', $pagerange='', $paged=''){
     85  if(empty($pagerange)){
    9686    $pagerange = 2;
    9787  }
    9888 
    99   if (empty($paged)) {
     89  if(empty($paged)){
    10090   global $paged;
    10191    $paged = 1;
    10292  }
    103   if ($numpages == '') {
     93  if($numpages == ''){
    10494    global $wp_query;
    10595    $numpages = $wp_query->max_num_pages;
    106     if(!$numpages) {
     96    if(!$numpages){
    10797        $numpages = 1;
    10898    }
     
    114104   */
    115105  $pagination_args = array(
    116     'base'            => get_pagenum_link(1) . '%_%',
    117     'format'          => 'page/%#%',
    118     'total'           => $numpages,
    119     'current'         => $paged,
    120     'show_all'        => False,
    121     'end_size'        => 1,
    122     'mid_size'        => $pagerange,
    123     'prev_next'       => True,
    124     'prev_text'       => __('&laquo;'),
    125     'next_text'       => __('&raquo;'),
    126     'type'            => 'plain',
    127     'add_args'        => false,
    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'    => __('&laquo;'),
     115    'next_text'    => __('&raquo;'),
     116    'type'         => 'plain',
     117    'add_args'     => false,
     118    'add_fragment' => ''
    129119  );
    130120
    131121  $lcpfi_paginate_links = paginate_links($pagination_args);
    132122
    133   if ($lcpfi_paginate_links) {
     123  if($lcpfi_paginate_links){
    134124     $lcpfi_pgdata = "<nav class='lcpfi-glpagination'>";
    135125      // echo "<span class='page-numbers page-num'>Page " . $paged . " of " . $numpages . "</span> ";
     
    138128    return $lcpfi_pgdata;
    139129  }
    140 
    141130 }
    142131 
    143132 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');
    149137 }
    150138?>
  • list-custom-post-with-featured-image/trunk/readme.txt

    r1699794 r2185342  
    11=== List Custom Post with featured image ===
    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:       4.8
    6 Stable tag:         1.0
    7 License:            GPLv2 or later
    8 License URI:        http://www.gnu.org/licenses/gpl-2.0.html
     2Contributors:      devikas301
     3Tags:              custom post grid, rockon, custom post list, shortcode, pagination, post, post image, title, vs
     4Requires at least: 3.6
     5Tested up to:      5.2
     6Stable tag:        1.1
     7License:           GPLv2 or later
     8License URI:       http://www.gnu.org/licenses/gpl-2.0.html
    99
    1010Simple plugin. Show feature image, title with pagination on anywhere using shortcode.
     
    3232== Shortcode ==
    3333
    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.