Plugin Directory

Changeset 2489374


Ignore:
Timestamp:
03/08/2021 10:09:43 AM (5 years ago)
Author:
rajeevglocify
Message:

update

Location:
load-more-posts/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • load-more-posts/trunk/css/custom.css

    r2478697 r2489374  
    134134.news-block-thumb img {width: 100%;}
    135135.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;}
    137137.wp_post_items h3 {font-size: 25px;}
    138138.wp_post_items h3 a {color: #333;}
  • load-more-posts/trunk/js/custom.js

    r2481384 r2489374  
    11//custom js
    22jQuery(document).ready(function(){
    3 
    43    // Load more data
    5     jQuery('.wp_load-more').click(function(){
     4    jQuery('.wp_load-more').on("click",function(){
    65        var wp_page_posts = Number(jQuery('#wp_page_posts').val());
    76        var wp_post_show = Number(jQuery('#wp_post_show').val());
     
    98        var wp_post_show1 = Number (wp_post_show + wp_page_posts);
    109        var cat_id = jQuery('#wp_cat_id').val();
     10        var post_type = jQuery('#wp_posType').val();
    1111        if(wp_post_show1 > allcount){
    1212            var limit_to = Number(allcount - wp_post_show);
     
    2424                dataType: "html",
    2525                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
    2727                    },
    2828                beforeSend:function(){
  • load-more-posts/trunk/loadmorepost.php

    r2486423 r2489374  
    66* Version: 1.2.0
    77* Author: Rajeev Chauhan
     8* Author URI: mailto:rajeev.glocify@gmail.com
    89* Text Domain: loadmorepost
    910* Domain Path: /lang
     
    4142    }
    4243    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");
    4445        wp_enqueue_style( 'wp_loadmore_css' );
    4546        wp_register_script( 'wp_loadmore_js', plugins_url('js/custom.js',__FILE__ ), array( 'jquery' ), "1.2.2");
     
    5152        'hide_btn_Txt' => get_option('wp_hide_btn_Txt','Load Less'),       
    5253        'load_less_btn' => get_option('wp_load_less_Btn','0'),     
    53         );
     54            );
    5455        wp_localize_script( 'wp_loadmore_js', 'loadMoreJS', $translation_array );       
    5556        wp_enqueue_script( 'wp_loadmore_js');
     
    7071    function wp_load_more_option($atts){
    7172        $atts = shortcode_atts(
    72             array('cat_id' => false),
     73            array('cat_id' => false,'post_type' => false),
    7374            $atts
    74         );
     75        );     
     76        $post_type = $atts['post_type'];
    7577        $cat_ID = $atts['cat_id'];     
    7678        $rowperpage = get_option('wp_post_per_page');
    7779        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)){
    7990            $the_query = new WP_Query( 'cat='.$cat_ID );
    8091            $allcount = $the_query->found_posts;
     
    8293            $allcount = wp_count_posts('post')->publish;
    8394        }
     95        if(empty($post_type)){$post_type = 'post';}
    8496        $html ='';
    8597        if($allcount>0):
     
    90102        'orderby'          => 'date',
    91103        'order'            => 'DESC',
    92         'post_type'        => 'post',
     104        'post_type'        => $post_type,
    93105        'post_status'      => 'publish'
    94106       );
     
    102114            $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>';
    103115        }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>';    
    105117        }
    106118        foreach($results as $result){           
     
    160172         <input type="hidden" id="wp_post_show" value="'.$rowperpage.'">
    161173         <input type="hidden" id="wp_all" value="'. $allcount .'">
     174         <input type="hidden" id="wp_posType" value="'. $post_type .'">
    162175         <input type="hidden" id="wp_cat_id" value="'. $cat_ID .'"></div>';
    163176         endif;     
     
    172185        $limit_to = sanitize_text_field($_POST['limit_to']);
    173186        $cat_id = sanitize_text_field($_POST['cat_id']);
     187        $post_type = sanitize_text_field($_POST['post_type']);
    174188        $args = array(
    175189                'numberposts'      => $limit_to,
     
    178192                'orderby'          => 'date',
    179193                'order'            => 'DESC',
    180                 'post_type'        => 'post',
     194                'post_type'        => $post_type,
    181195                'post_status'      => 'publish'
    182196            );
  • load-more-posts/trunk/readme.txt

    r2486427 r2489374  
    2626* Any Category: [wp_load_more_option cat_id="1"] -- Where 1 is category id.
    2727* 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.
    2829
    2930== Changelog ==
     
    48493. How can I show all posts for multiple categories?
    4950   Use shortcode for any page [wp_load_more_option cat_id="1,3"] ***Where 1 and 3 are category id***
     51   
     524. 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.***
    5054
    5155== Upgrade Notice ==
Note: See TracChangeset for help on using the changeset viewer.