Tuesday, 26 October 2021

123.pagination and load more in wordpress

  <section class="ftco-section bg-light">

      <div class="container">
        <div class="row">
          <?php
         
            $wpb_all_query = new WP_Query( array(
            // 'posts_per_page' => 6,
            'post_type'=>'post', 'post_status'=>'publish',
            'paged' => get_query_var('paged') ? get_query_var('paged') : 1) );


          if ( $wpb_all_query->have_posts() ) :
            while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post();
     
      $imag_url= get_the_post_thumbnail_url();    
          ?>  
          <div class="col-md-4 ftco-animate life-style">
            <div class="blog-entry">
              <span href="#" class="block-20" style="background-image: url(<?php echo $imag_url; ?>);"></span>
              <div class="text pt-3 pb-4 px-4">
                <div class="meta">                
                  <div><span class="life_style_text"><?php the_title(); ?></span></div>                  
                </div>
                <h3 class="heading"><a href="#" ><?php the_content(); ?></a></h3>
                <p class="clearfix">
                <?php the_content(); ?>
                </p>
              </div>
            </div>
          </div>
          <?php endwhile; ?>
      <?php else:?>
     
        no post found
   
      <?php endif; wp_reset_postdata(); ?>
         
         
        </div>
       
        <?php /*
          <div class="row no-gutters my-5 ">
          <div class="col text-center">
            <div class="block-27">
            <div style="clear:both;">
            <ul>
           
            <li>
            <?php
           
            $big = 999999999; // need an unlikely integer
            echo paginate_links( array(
                'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
                'format' => '?paged=%#%',
                'current' => max( 1, get_query_var('paged') ),
                'total' => $wpb_all_query->max_num_pages
            ) );
           
            wp_reset_postdata(); ?>
            </li>
           
            </ul>
            </div>              
            </div>
          </div>
          </div>
          */?>
         
          <div class="form-group text-center">
          <a href="" class="load-more" id="seeMore">Load More</a>
          </div>
         



      </div>
    </section>




<script>
  $(document).ready(function(){
  $(".life-style").slice(0,6).show();
  $("#seeMore").click(function(e){
    e.preventDefault();
    $(".life-style:hidden").slice(0,6).fadeIn("slow");
   
    if($(".life-style:hidden").length == 0){
       $("#seeMore").fadeOut("slow");
      }
  });
})
  </script>

Friday, 9 July 2021

122.adding tag and category of a post in a custom post tyle

a .     tag and category                      

   'taxonomies' => array('category', 'post_tag')

b . tag

            'taxonomies' => array('post_tag')

121.tags in wordpress

 add_action( 'init', 'create_topics_nonhierarchical_taxonomy', 0 );

 
function create_topics_nonhierarchical_taxonomy() {
 
// Labels part for the GUI
 
  $labels = array(
    'name' => _x( 'Tags', 'taxonomy general name' ),
    'singular_name' => _x( 'Tag', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Tag' ),
    'popular_items' => __( 'Popular Tag' ),
    'all_items' => __( 'All Tags' ),
    'parent_item' => null,
    'parent_item_colon' => null,
    'edit_item' => __( 'Edit Tag' ), 
    'update_item' => __( 'Update Tag' ),
    'add_new_item' => __( 'Add New Tag' ),
    'new_item_name' => __( 'New Tag Name' ),
    'separate_items_with_commas' => __( 'Separate tag with commas' ),
    'add_or_remove_items' => __( 'Add or remove tag' ),
    'choose_from_most_used' => __( 'Choose from the most used tags' ),
    'menu_name' => __( 'Tag' ),
  ); 
 
// Now register the non-hierarchical taxonomy like tag
 
  register_taxonomy('topics','cities',array(
    'hierarchical' => false,
    'labels' => $labels,
    'show_ui' => true,
    'show_in_rest' => true,
    'show_admin_column' => true,
    'update_count_callback' => '_update_post_term_count',
    'query_var' => true,
    'rewrite' => array( 'slug' => 'topic' ),
  ));
}

Thursday, 8 July 2021

120.disable the block editor only for particular post types

 add_filter('use_block_editor_for_post_type', 'prefix_disable_gutenberg', 10, 2);

function prefix_disable_gutenberg($current_status, $post_type)
{
    // Use your post type key instead of 'product'
    if ($post_type === 'cities') return false;
    return $current_status;
}

Saturday, 6 February 2021

 119.how to append html contents in popup in codeigniter using jquery

above footer


<!-- send modal -->
<div class="modal fade" id="privi_popup" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
            
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">Privilege Card</h4>
                </div>
            
                <div class="modal-body" id="priv_body">
                    

                </div>
                
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>    
                </div>
            </div>
        </div>
    </div>
<!-- end delete modal -->

js
$("#privilege_card").change(function(){
                 
                  var barcode_id    =  $('#privilege_card').val();

                  $('#privi_popup').modal('show');

                  $.ajax({         
                     
                     url      : "<?php echo base_url(); ?>" + "User/privilege_card_popup",
                     data     : {barcode_id:barcode_id},
                     dataType : 'html',
                     type     : 'POST',      
                  
                     success: function (data) {
        
                          $("#priv_body").html(data);
                         // alert(data.result);
                      
                     },
                     error: function() {
                        alert('Something is wrong');
                     },
                   
                  });
 });


    public function privilege_card_popup()
    {       
        $barcode = $this->input->post('barcode_id');

        $user_id = ltrim($barcode'0');

        $this->load->model('Model_users');
        
        $user_details['user']       =   $this->Model_users->get_user_org_details($user_id);

         $user_details['barcode']    =  "".base_url()."application/libraries/barcode/barcode_new.php?codetype=Code128&size=40&text=$barcode&print=true";

        $this->db->select("*");

        $this->db->from('tb_admin_settings');

        $settings                    =  $this->db->get()->row();

        $user_details['settings']    =  $settings;
        
        $this->load->view('pages/theme-bc1',$user_details);
        
    }


Tuesday, 19 January 2021

 118.codeigniter left join

$this->db->select('u.*,o.*');
        $this->db->from('tb_end_users as u');
        $this->db->join('tb_organizations as o''o.org_id = u.org_id','left');
        $this->db->where('u.euser_pk_id'$dpno);       
        $query=$this->db->get()->result();
        //print_r($this->db->last_query());  //to print query
        return $query;

Sunday, 17 January 2021

 117.ajax delete using modal in codeigniter

<a class="btn btn-default org_del_<?php  echo $r->org_id;?>" href="#"  id="<?php  echo $r->org_id;?>" onclick="deleteorg(<?php  echo $r->org_id;?>)">Delete</a>


before footer

<!-- delete modal -->
<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
            
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">Confirm Delete</h4>
                </div>
            
                <div class="modal-body">
                    <p>You are about to delete one track, this procedure is irreversible.</p>
                    <p>Do you want to proceed?</p>
                    <p class="debug-url"></p>
                </div>
                
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                    <a class="btn btn-danger btn-ok" onclick="confirmdelete()">Delete</a>
                </div>
            </div>
        </div>
    </div>
<!-- end delete modal -->


js
function deleteorg(id){
$('#confirm-delete').modal('show');

$(".btn-ok").click(function(){

   $.ajax({         
      url: "<?php echo base_url(); ?>" + "User/org_del_ajax",
      data : {org_id:id},
      dataType: 'json',
      type: 'POST',      

      error: function() {
         alert('Something is wrong');
      },
      success: function (data) {
          jQuery('.org_'+id).remove();
          $('#confirm-delete').modal('hide');
            },
   });

});

}


controller
    public function org_del_ajax()
    {
        
    $orgid=$this->input->post('org_id');

    $result=$this->db->delete('tb_organizations'array('org_id' => $orgid));

    echo json_encode($result);
    
    }