Ver código fonte

Faculty archive info from api

Md Mozahidur Rahman 1 ano atrás
pai
commit
9a9d3c2dd1
2 arquivos alterados com 48 adições e 5 exclusões
  1. 42 5
      archive-faculty.php
  2. 6 0
      css/theme-styles.css

+ 42 - 5
archive-faculty.php

@@ -29,7 +29,42 @@ get_header();
 			<div class="parent-grid">
 
 				<?php if (have_posts()) : ?>
-					<?php while (have_posts()) : the_post(); ?>
+					<?php while (have_posts()) : the_post();
+
+						$login_id_e = "";
+						$auth_token = get_field('auth_token', 'option');
+						$client_id = get_field('client_id', 'option');
+						$employee_info_api = get_field('employee_info_api', 'option');
+
+						if (function_exists('get_field')) {
+							$pid_content = get_post();
+							if (has_blocks($pid_content)) {
+								$blocks = parse_blocks($pid_content->post_content);
+								foreach ($blocks as $block) {
+									if ($block["blockName"] == "acf/faculty-member") {
+										// $FullName = $block['login_id_e'];
+										$login_id_e = $block["attrs"]["data"]["login_id"];
+										// $Designation = $block["attrs"]["data"];
+									}
+								}
+							}
+						};
+
+						$response_employeeInfo = wp_remote_post(
+							$employee_info_api,
+							array(
+								'body' => array(
+									'user_login_id' => $client_id,
+									'login_id' => $login_id_e,
+									'auth_token' => $auth_token
+								)
+							)
+						);
+						$employeeInfo = json_decode(wp_remote_retrieve_body($response_employeeInfo), true);
+						$Title = $employeeInfo[0]['Title'];
+						$FullName = $Title . ' ' . $employeeInfo[0]['FullName'];
+						$Designation = $employeeInfo[0]['Designation'] . ' ' . $employeeInfo[0]['Office'];
+					?>
 
 
 						<div class="faculty-stub grid-sub-item">
@@ -40,12 +75,14 @@ get_header();
 							<a class="faculty-link" href="<?php echo get_the_permalink(); ?>">
 								<div class="archive-faculty-details">
 
-									<h3><?php echo get_the_title(); ?></h3>
+									<h3>
+										<?php echo $FullName; ?><span class="degree"><?php if ($Title == "Dr.") {
+																							echo ', PhD';
+																						} ?></span>
+									</h3>
 
 									<span class="faculty-designation">
-										Department of Computer Science and Engineering
-										<?php //the_field('designation');
-										?>
+										<?php echo $Designation; ?>
 									</span>
 
 								</div>

+ 6 - 0
css/theme-styles.css

@@ -1770,4 +1770,10 @@ body.archive aside#secondary{
     margin-bottom: 0!important;
     max-height:unset!important;
     width: calc(25% - 25px);
+}
+
+span.degree {
+    font-weight: normal;
+    font-size: 13px;
+    font-style: italic;
 }