Advertisement
jimlohse

Untitled

Oct 1st, 2024
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.51 KB | Source Code | 0 0
  1. <?php //this lasts for a bit, through the function def
  2. /**
  3.  * Template Name: Advisors Listing
  4.  * The template for displaying all advisors grouped by their category.
  5.  */
  6.  
  7. function show_employee_block($employee_record)
  8. {
  9.     print("Hello about to print employee record from show employee block");
  10.     var_dump($employee_record);
  11.     ?>
  12.     <img src=<?php echo esc_url($employee_record->advisor_image_link) ?> alt="<?php echo esc_html($employee_record->advisor_name); ?>" title=""/>)
  13.     <div class="attorney-information clearfix">
  14.         <div class="attorney-name-label">
  15.             <h3>
  16.                 <?php esc_html($employee_record->advisor_name); ?>
  17.             </h3>
  18.             <span class="label-text underline-label">
  19.           <?php esc_html($employee_record->designation); ?>
  20.         </span>
  21.         </div>
  22.         <p>
  23.             <?php esc_html($employee_record->advisor_description); ?>
  24.         </p>
  25.     </div>
  26.  
  27.     <?php
  28. }
  29.  
  30. get_header();
  31. echo 'Memory limit: ' . ini_get('memory_limit');
  32.  
  33. // ini_set('memory_limit', '1024M');
  34. // echo 'Memory limit: ' . ini_get('memory_limit');
  35.  
  36. // this is the closing tag for the opening php tag
  37. ?>
  38.  
  39. <section class="banner-one" id="slider">
  40.     <?php $PageBanner = ot_get_option('attorney_single_legal_consulation_background'); ?>
  41.     <div class="about-banner" style="background: url(<?php echo $PageBanner ?> );">
  42.         <div class="container banner-text">
  43.             <div class="row">
  44.                 <div class="col-xs-12">
  45.                     <?php $PageHeading = ot_get_option('attorney_single_heading'); ?>
  46.                     <?php if (!empty($PageHeading)): ?>
  47.                         <h1 style="font-size:400%;"><?php echo esc_html($PageHeading); ?></h1>
  48.                     <?php endif; ?>
  49.                 </div>
  50.             </div>
  51.         </div>
  52.     </div>
  53. </section>
  54.  
  55. <!--content Section Start Here -->
  56. <div id="content">
  57.     <!--advisors-listing-container Section Start Here -->
  58.     <!--    <section class="advisors-listing-container">-->
  59.     <section class="attorney-listing">
  60.         <div class="container">
  61.             <div class="row">
  62.                 <div class="col-xs-12 col-sm-6 col-md-4 attorney-listing-box zoom">
  63.                     <?php
  64.                     // Initialize an empty array to hold employees by category
  65.                     $employees = [];
  66.  
  67.                     // Query custom post type 'advisor'
  68.                     $args = [
  69.                         'post_type' => 'attorney',
  70.                         'posts_per_page' => -1, // Get all advisor posts
  71.                     ];
  72.  
  73.                     $advisor_query = new WP_Query($args);
  74.                     //                    $total = $advisor_query->found_posts;
  75.                     //                    echo("Total posts: " . $total);
  76.                     echo("This is the memory usage before the input loop");
  77.                     echo("Memory used: " . memory_get_usage() . " bytes");
  78.  
  79.                     if ($advisor_query->have_posts()):
  80.                         while ($advisor_query->have_posts()):
  81.  
  82.                             // $advisor_query->the_post();
  83.                             // get the designation to be able to lower case it
  84.                             $designation = get_post_meta(get_the_id(), 'attorney_designation', true);
  85.                             $designation_lower = strtolower(get_post_meta(get_the_id(), 'attorney_designation', true));
  86.  
  87.                             // Get the designation (role/title) of the advisor
  88.                             $advisor_record = [
  89.                                 "advisor_name" => get_the_title(),
  90.                                 "designation" => $designation,
  91.                                 "designation_lower" => $designation_lower,
  92.                                 "advisor_description" => get_the_content(),
  93.                                 "advisor_image_link" => get_post_meta(get_the_id(), 'attorney_detailed_page_image', true),
  94.                             ];
  95.  
  96.                             // Categorize employees based on designation
  97.                             // if (strpos($designation_lower, 'shareholder') !== false) {
  98.                             if (str_contains($designation_lower, 'shareholder')) {
  99.                                 $employees['shareholders'][] = $advisor_record;
  100.                             } elseif (str_contains($designation_lower, 'cpa') || str_contains($designation_lower, 'accountant') || str_contains($designation_lower, 'tax advisor')) {
  101.                                 $employees['cpas'][] = $advisor_record;
  102.                             } else {
  103.                                 $employees['admin'][] = $advisor_record;
  104.                             }
  105.  
  106.                             echo("This is the memory usage during the input loop");
  107.                             echo("Memory used: " . memory_get_usage() . " bytes");
  108.                             wp_reset_postdata();
  109.                             echo("This is the memory usage after resetting post data in the loop");
  110.                             echo("Memory used: " . memory_get_usage() . " bytes");
  111.  
  112.                             wp_reset_postdata();
  113.  
  114.                         endwhile;
  115.                     endif;
  116.  
  117.                     echo("This is the memory usage before wp_reset_postdata");
  118.                     echo("Memory used: " . memory_get_usage() . " bytes");
  119.                     // wp_reset_postdata();
  120.                     echo("This is the memory usage after wp_reset_postdata");
  121.                     echo("Memory used: " . memory_get_usage() . " bytes");
  122.                     ?>
  123.  
  124.                     <!-- Output Employee Groups -->
  125.                     <?php if (!empty($employees)) : ?>
  126.                         <div class="employee-groups">
  127.  
  128.                             <!-- Shareholders Group -->
  129.                             <?php if (!empty($employees['shareholders'])) : ?>
  130.                                 <h1 style="font-family: 'Lato';font-size:200%;">Shareholders</h1>
  131.                                 <?php foreach ($employees['shareholders'] as $shareholder) :
  132.                                     show_employee_block($shareholder);
  133.                                 endforeach;
  134.                             endif; ?>
  135.  
  136.                             <!-- CPAs/Accountants Group -->
  137.                             <?php if (!empty($employees['cpas'])) : ?>
  138.                                 <h1 style="font-family: 'Lato';font-size:200%;">Accountants / CPAs</h1>
  139.                                 <?php foreach ($employees['cpas'] as $cpa) :
  140.                                     show_employee_block($cpa);
  141.                                 endforeach;
  142.                             endif; ?>
  143.  
  144.                             <!-- Administrative Staff Group -->
  145.                             <?php if (!empty($employees['admin'])) : ?>
  146.                                 <h1 style="font-family: 'Lato';font-size:200%;">Administrative Staff</h1>
  147.                                 <?php foreach ($employees['admin'] as $admin) :
  148.                                     show_employee_block($admin);
  149.                                 endforeach;
  150.                             endif; ?>
  151.  
  152.                         </div>
  153.                     <?php else: ?>
  154.                         <p>No advisors found on this run.</p>
  155.                     <?php endif; ?>
  156.  
  157.                 </div>
  158.             </div>
  159.         </div>
  160.     </section>
  161.     <!--advisors-listing-container Section End Here -->
  162. </div>
  163. <!--content Section End Here -->
  164.  
  165. <?php get_footer(); ?>
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
Tags: php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement