bongzilla

Untitled

Jan 31st, 2022 (edited)
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. <?php
  2. $agent_name = $product->get_attribute( 'pa_imya-agenta' );
  3.  
  4. $posts = get_posts(array(
  5.     'numberposts'   => -1,
  6.     'post_type'     => 'comands',
  7.     'meta_query'    => array(
  8.         'relation'  => 'AND',
  9.         array(
  10.             'key'   => 'metka',
  11.             'value' => array($agent_name),
  12.             'compare' => 'IN',
  13.         ),
  14.     ),
  15. ));
  16.                                
  17. $products = new WP_Query( array(
  18.    'post_type'      => array('product'),
  19.    'post_status'    => 'publish',
  20.    'posts_per_page' => -1,
  21.    'tax_query'      => array( array(
  22.         'taxonomy'  => 'pa_imya-agenta',
  23.         'field'     => 'name',
  24.         'terms'     =>  array($agent_name),
  25.         'operator'  => 'IN',
  26.     ) )
  27. ) );
  28.                    
  29. $slug = $posts[0]->post_name;
  30. $agent_page_link = "https://praid-pro.ru/comands/" . $slug . "/";
  31. $objects_count = count($products->posts);
  32. $objects_count_string = num_decline($objects_count, array("объект", "объекта", "объектов"));
  33.  
  34. $vars = [
  35.   $agent_page_link,
  36.   $objects_count_string
  37. ];
  38.  
  39. $result = sprintf('<div class="label_spec">Специалист по недвижимости</div><a href="%s" class="object_spec">Объекты специалиста</a></div><a data-w-id="c5da5e96-65e0-9450-40ff-4c3f22b7758c" href="#" class="btn_call_spec w-button">задать вопрос</a></div>', ...$vars);
  40.  
  41. echo $result;
  42. ?>    
Add Comment
Please, Sign In to add comment