Advertisement
Gecata1

ACF Relationship

Mar 28th, 2024
705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1. add_filter( 'woocommerce_product_tabs', 'edscom_savmestimi_produkti_tab' );
  2. function edscom_savmestimi_produkti_tab( $tabs ) {
  3.     global $post;
  4.     $my_savmestimi_produkti = get_field( 'savmestimi_produkti', );
  5.     if( ! empty( $my_savmestimi_produkti )) {
  6. // Adds the new tab
  7.     $tabs['savmestimi-produkti'] = array (
  8.         'title'     => __( 'Съвместими продукти', 'woocommerce' ),
  9.         'priority'  => 12,
  10.         'callback'  => 'edscom_savmestimi_produkti_tab_content'
  11.     );
  12.     }
  13.     return $tabs;
  14. }
  15. function edscom_savmestimi_produkti_tab_content() {
  16.     $the_articles = get_field('savmestimi_produkti');
  17.     if( $the_articles ): ?>
  18.         <div class="tab-savmestimi">
  19.         <ul style="list-style-type: none; padding-left: 15px;">
  20.         <?php foreach( $the_articles as $article ): ?>
  21.             <li>
  22.                
  23.                 <a href="<?php echo get_permalink($article->ID); ?>" title="<?php echo __('Още за ') . ' ' . $article->post_title; ?>" target="_blank">
  24.                 <img width="50" height="50" class="img_tsprod" src="<?php echo get_the_post_thumbnail_url( $article->ID ); ?>">
  25.                 <?php echo $article->post_title; ?>
  26.                 </a>
  27.         </li>
  28.         <?php endforeach; ?>
  29.     </ul>
  30.     </div>
  31. <?php endif;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement