HEX
Server: Apache
System: Linux srv-plesk28.ps.kz 5.14.0-284.18.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 29 17:06:27 EDT 2023 x86_64
User: greencl1 (10085)
PHP: 8.1.33
Disabled: apache_setenv,dl,eval,exec,openlog,passthru,pcntl_exec,pcntl_fork,popen,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,socket_create,socket_create_listen,socket_create_pair,syslog,system,socket_listen,stream_socket_server
Upload Files
File: /var/www/vhosts/greenclinic.kz/newsite/wp-content/themes/green-clinic/category-photo-gallery.php
<?php
/**
 * The template for displaying archive pages
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package asds
 */

get_header();
$the_post = get_the_ID();

$term = get_the_category( $the_post );
$term_id = $term[0]->term_id;
// параметры по умолчанию
$my_posts = get_posts( array(
	'numberposts' => 5,
	'category'    => $term_id,
	'orderby'     => 'date',
	'order'       => 'DESC',
	'include'     => array(),
	'exclude'     => array(),
	'meta_key'    => '',
	'meta_value'  =>'',
	'post_type'   => 'post',
	'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
) );

global $post;

 


?>
<?php get_template_part( 'template-parts/content_header', 'none' ); ?>  

<section class="section content_section">
	<main id="primary" class="site-main container">
   
    <script>
        let data = [

        
    <?php foreach($my_posts as $post): ?>
        <?php 
            $post_id = $post->ID;
            //echo $post_id;
            $post_title = $post->post_title;
           // echo esc_html($post_title);
            $post_url = $post->guid; 
            //echo $post_url;
            $photo_field = the_field( 'photo_gallery', $post_id ); 
        ?>
        <?php 

          if(have_rows('blocks', $post_id)):
            while(have_rows('blocks', $post_id)): the_row(); ?> 
            <?php $list = get_sub_field('list'); $list_count = count($list)?>
            <?php $image_url = $list[0]["photo"]["url"]; ?>

            

            
          {
          id: <?php echo $post_id ?>,
          title: "<?php echo esc_html($post_title); ?>",
          img: "<?php echo $image_url; ?>",
          photosLength: <?php echo $list_count ?>,
          photosUrl: '<?php echo $post_url ?>',
          },
            
            
        <?php endwhile; 
            endif;
        ?> 
        ];

        <?php endforeach; ?>    
    </script>
        
         
        

    
    <div class="photogallery__container" id="photogallery__container"></div>
    <?php wp_reset_postdata();  ?>
	</main><!-- #main -->
</section>
<script>
      

      const photogalleryContainer = document.getElementById(
        "photogallery__container"
      );

      photogalleryContainer.innerHTML = "";

      data.forEach((item, index) => {
        let albumDiv = document.createElement("div");
        albumDiv.classList.add("album");
        albumDiv.classList.add("pointer");
        albumDiv.innerHTML += `
		  <div class="album-content"><a href="${item.photosUrl}">
				<div class="album-text">
				<p>${item.photosLength} фото</p>
				<div class="album-title">
					<h4>${item.title}</h4>
					<svg width="19" height="19" viewBox="0 0 19 19" fill="none" xmlns="http://www.w3.org/2000/svg">
  <path d="M15.832 9.5L16.1856 9.14645L16.5391 9.5L16.1856 9.85355L15.832 9.5ZM3.95703 10C3.68089 10 3.45703 9.77614 3.45703 9.5C3.45703 9.22386 3.68089 9 3.95703 9V10ZM11.4356 4.39645L16.1856 9.14645L15.4785 9.85355L10.7285 5.10355L11.4356 4.39645ZM16.1856 9.85355L11.4356 14.6036L10.7285 13.8964L15.4785 9.14645L16.1856 9.85355ZM15.832 10H3.95703V9H15.832V10Z" fill="white"/>
</svg>
</div>
					</div></a>
					</div>
			`;

			albumDiv.style.backgroundImage = `url('${item.img}')`;

        photogalleryContainer.appendChild(albumDiv);
      });
</script>
<?php get_footer(); ?>