Setting the_post_thumbnail width to 100% - wordpress

How to set the_post_thumbnail so that it doesn't use an array for its size, but instead can be set with a 100% width and auto height:
<?php $ht_featured_img = get_option('ht_featured_img');
if ($ht_featured_img == "true") { ?>
<?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) { /* if post has a thumbnail */ ?>
<div class="post-image">
<?php the_post_thumbnail( array(1215,9999) ); ?>
</div><!--post-image-->
<?php } ?>
<?php } ?>

<?php $ht_featured_img = get_option('ht_featured_img'); if ($ht_featured_img == "true") { ?>
<?php if ( ( function_exists('has_post_thumbnail') ) && ( has_post_thumbnail() ) ) {
$post_thumbnail_id = get_post_thumbnail_id();
$post_thumbnail_url = wp_get_attachment_url( $post_thumbnail_id );
?>
<div class="post-image">
<img title="image title" alt="thumb image" class="wp-post-image" src="<?php echo $post_thumbnail_url; ?>" style="width:100%; height:auto;">
</div>
<?php } ?>
<?php } ?>

<? if( has_post_thumbnail( $post_id ) ): ?>
<div class="post-image">
<img title="image title" alt="thumb image" class="wp-post-image"
src="<?=wp_get_attachment_url( get_post_thumbnail_id() ); ?>" style="width:100%; height:auto;">
</div>
<? endif; ?>

You could also just use
<img src="<?php echo get_the_post_thumbnail_url (); ?>" style="width:100%; height:auto;">

Related

Wordpress showing featured post card below each post, need to show featured on the featured page

I am working on a website that has a section below the blog post that shows a marked featured post, the issue I am having is that on the featured page the card section is showing the 1st post on the post list instead of its own featured post.
This is setup in a component-card.php
<?php
$post_id = (get_query_var('post_id')) ? get_query_var('post_id') : $post->ID;
$type = get_query_var('type');
$pages = get_query_var('pages');
$col = get_query_var('col');
$image = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'single-post-thumbnail');
$show_featured = get_field("featured_story", $post_id);
$link = get_the_permalink($post_id);
$title = get_the_title($post_id);
$excerpt = get_the_excerpt($post_id);
$count = 6;
$switch = '';
if ($col === '12') {
$count = 12;
$switch = 'switch';
}
?>
<?php if ($type !== 'page'): ?>
<?php if ($show_featured): ?>
<article class="component-article-cards featured">
<div class="row align-middle align-center">
<div class="col-12 col-md-<?php echo $count ?> <?php echo $switch ?>">
<div class="article-inner">
<h3><?php echo $title; ?></h3>
<hr />
<?php echo $excerpt; ?>
Read full article
</div>
</div>
<div class="col-12 col-md-<?php echo $count ?>">
<?php if ($image) : ?>
<img src="<?php echo $image[0]; ?>">
<?php endif; ?>
</div>
</div>
</article>
<?php else: ?>
<article class="component-article-cards">
<?php if ($image) : ?>
<img src="<?php echo $image[0]; ?>">
<?php endif; ?>
<div class="article-inner">
<h3><?php echo $title; ?></h3>
<hr />
<?php echo $excerpt; ?>
Read full article
</div>
</article>
<?php endif; ?>
<?php endif; ?>
Any help would be gratefully appreciated

Problem with displaying wooccomerce related products

Bello my singleproduct.php, but my related products not shown on all categories, some work and some no, it is depend on query and fonts. For example here is work https://avestone.ru/product-category/nashi-raboti/, but if I change name of category it will not work. And it does not work at all at any russian named category.
<?php
/**
* The Template for displaying all single products
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* #see https://docs.woocommerce.com/document/template-structure/
* #package WooCommerce\Templates
* #version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
get_header(); ?>
<div class="popup_form" id="popup_form_product">
<div class="popup_form_content" id="popup_form_content_product">
<a href="javascript:PopUpHide()" class="popup_close">
<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M17.1875 4.8125L4.8125 17.1875" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M17.1875 17.1875L4.8125 4.8125" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</a>
<div class="form_title">Заказать расчет</div>
<?php echo do_shortcode( '[contact-form-7 id="6241" title="Попап товары"]' ); ?>
</div>
</div>
<?php
/**
* woocommerce_before_main_content hook.
*
* #hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* #hooked woocommerce_breadcrumb - 20
*/
do_action( 'woocommerce_before_main_content' );
?>
<div id="product-<?php the_ID(); ?>" <?php wc_product_class( '', $product ); ?>>
<div class="product_content">
<div class="breadcrumb">
<?php $values = get_the_terms( $product->id, 'pa_brend'); ?>
<ul>
<li>Каталог</li>
<li> - </li>
<li>
<?php foreach ( $values as $value ) {
echo '' . $value->name .'';
} ?></li>
<li> - </li>
<li><?php the_title(); ?></li>
</ul>
</div>
<?php the_title( '<h1 class="product_title mobile-product_title">', '</h1>' ); ?>
<?php while ( have_posts() ) : ?>
<?php the_post(); ?>
<div class="product_top_content">
<div class="product_top_content_block">
<div class="product_img">
<?php
$columns = apply_filters( 'woocommerce_product_thumbnails_columns', 4 );
$post_thumbnail_id = $product->get_image_id();
$wrapper_classes = apply_filters(
'woocommerce_single_product_image_gallery_classes',
array(
'woocommerce-product-gallery',
'woocommerce-product-gallery--' . ( $post_thumbnail_id ? 'with-images' : 'without-images' ),
'woocommerce-product-gallery--columns-' . absint( $columns ),
'images',
)
);
?>
<div class="<?php echo esc_attr( implode( ' ', array_map( 'sanitize_html_class', $wrapper_classes ) ) ); ?>" data-columns="<?php echo esc_attr( $columns ); ?>" style="opacity: 0; transition: opacity .25s ease-in-out;">
<figure class="woocommerce-product-gallery__wrapper">
<?php
if ( $post_thumbnail_id ) {
$html = wc_get_gallery_image_html( $post_thumbnail_id, true );
} else {
$html = '<div class="woocommerce-product-gallery__image--placeholder">';
$html .= sprintf( '<img src="%s" alt="%s" class="wp-post-image" />', esc_url( wc_placeholder_img_src( 'woocommerce_single' ) ), esc_html__( 'Awaiting product image', 'woocommerce' ) );
$html .= '</div>';
}
echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, $post_thumbnail_id ); // phpcs:disable WordPress.XSS.EscapeOutput.OutputNotEscaped
do_action( 'woocommerce_product_thumbnails' );
?>
</figure>
</div>
</div>
</div>
<div class="product_top_content_block product_top_content_block_right">
<?php the_title( '<h1 class="product_title">', '</h1>' ); ?>
<ul class="product_atr">
<li>Категория: <?php $cats_arr = wc_get_product_category_list( $product->get_id()); $cat_arr = explode(",", $cats_arr); echo $cat_arr[0];?></li>
<?php echo $product->list_attributes(); ?>
<li><?php esc_html_e( 'SKU:', 'woocommerce' ); ?> <span><?php echo $product->get_sku(); ?><span></li>
</ul>
<?php if( $product->get_price_html()) { ?>
<div class="product_price">
<p class="<?php echo esc_attr( apply_filters( 'woocommerce_product_price_class', 'price' ) ); ?>"><span><?php echo $product->get_price_html(); ?></span> РУБ / м2</p>
<div class="single_product_text">Cтоимость за квадратный метр материала, без учета стоимости изготовления, доставки и монтажа изделия</div>
</div>
<?php } ?>
<form class="product_price_cart cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data'>
<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
<div class="single_product_btn">
Расчитать стоимость
</div>
</form>
</div>
</div>
<?php $the_content = apply_filters( 'the_content', get_the_content() ); ?>
<div class="product_text_container">
<div class="product_text_tabs">
<?php if ( ! empty( $the_content ) ) : ?>
<div class="product_text_tab_title tab_1 active">Описание</div>
<?php endif; ?>
<?php if( have_rows('reviews') ): ?>
<div class="product_text_tab_title tab_2 <?php if ( empty( $the_content ) ) echo 'active'; ?>">Отзывы <span class="count"></span></div>
<?php endif; ?>
</div>
<div class="product_text_tabs_content">
<div class="product_text text_tab_1 active">
<?php the_content(); ?>
</div>
<div class="product_text text_tab_2 <?php if ( empty( $the_content ) ) echo 'active'; ?>">
<div class="product_text_review_container">
<?php
$count=1;
if( have_rows('reviews') ):
while ( have_rows('reviews') ) : the_row(); ?>
<div class="product_review_block">
<div class="product_review_block_left">
<?php if( get_sub_field('doc') ): ?>
<div class="product_review_title"><?php the_sub_field('doc'); ?></div>
<?php endif; ?>
<ul class="product_review_list">
<?php if( get_sub_field('client') ): ?>
<li>Заказчик: <?php the_sub_field('client'); ?></li>
<?php endif; ?>
<?php if( get_sub_field('adress') ): ?>
<li>Адрес: <?php the_sub_field('adress'); ?></li>
<?php endif; ?>
<?php if( get_sub_field('stone') ): ?>
<li>Камень: <?php the_sub_field('stone'); ?></li>
<?php endif; ?>
<?php if( get_sub_field('price') ): ?>
<li>Стоимость: <?php the_sub_field('price'); ?></li>
<?php endif; ?>
</ul>
<div class="product_review_text product_review_text-<? echo $count?>">
<?php if( get_sub_field('text') ): ?>
<div class="product_review_text_title">Текст:</div>
<p><?php the_sub_field('text'); ?></p>
Показать весть текст
<?php endif; ?>
</div>
</div>
<div class="product_review_block_right">
<?php if( have_rows('gallery') ): ?>
<div class="slider-review-for">
<?php while( have_rows('gallery') ): the_row();?>
<div class="slider-review-for-box"><img src="<?php echo get_sub_field('img'); ?>" alt="<?php echo $image['alt']; ?>"></div>
<?php endwhile; ?>
</div>
<div class="slider-review-nav">
<?php while( have_rows('gallery') ): the_row();?>
<div class="slider-review-nav-box"><img src="<?php echo get_sub_field('img'); ?>" alt="<?php echo $image['alt']; ?>"></div>
<?php endwhile; ?>
</div>
<?php endif; ?>
</div>
</div>
<?php
$count++;
endwhile;
endif;
?>
<div class="product_text_review_container_btn">Показать все отзывы</div>
</div>
</div>
</div>
</div>
<?php endwhile; // end of the loop. ?>
<?php
$cats_arr = wc_get_product_category_list( $product->get_id()); $cat_arr = explode(",", $cats_arr); $cat = $cat_arr[0]; $mycat = preg_replace('#<a.*?>|</a>#sui', '', $cat);
$id5 = get_the_ID();
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => 4,
'orderby' => 'rand',
'post__not_in' => array($id5),
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'terms' => $mycat,
'field' => 'slug',
),
)
);
$loop = new WP_Query($args);
if ($loop->have_posts())
{ ?>
<div class="relative_products">
<h2>Похожие камни:</h2>
<div class="relative_products_container">
<div class="woocommerce columns-4 ">
<ul class="products oceanwp-row clr grid">
<?php
while ($loop->have_posts()):
$loop->the_post(); ?>
<li class="entry has-media col span_1_of_4 owp-content-left owp-thumbs-layout-horizontal owp-btn-normal owp-tabs-layout-horizontal product type-product post-5856 status-publish first instock product_cat-classical product_cat-95 has-post-thumbnail shipping-taxable purchasable product-type-simple">
<div class="product-inner clr">
<div class="woo-entry-image clr">
<?php if (has_post_thumbnail()): ?>
<img src="<?php the_post_thumbnail_url('large'); ?>" alt="<?php the_title(); ?>">
<?php endif; ?>
</div><!-- .woo-entry-image -->
<ul class="woo-entry-inner clr">
<li class="image-wrap">
<div class="woo-entry-image clr">
<?php if (has_post_thumbnail()): ?>
<img src="<?php the_post_thumbnail_url('large'); ?>" alt="<?php the_title(); ?>">
<?php endif; ?>
</div><!-- .woo-entry-image -->
</li>
<li class="title"><?php the_title(); ?></li>
<li class="category">Категория <?php $cats_arr = wc_get_product_category_list( $product->get_id()); $cat_arr = explode(",", $cats_arr); echo $cat_arr[0];?></li>
</ul>
</div>
</li>
<?php
endwhile; ?>
</ul>
</div>
</div>
</div>
<?php } ?>
<?php
/**
* woocommerce_after_main_content hook.
*
* #hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
*/
do_action( 'woocommerce_after_main_content' );
?>
<?php
get_footer();
/* Omit closing PHP tag at the end of PHP files to avoid "headers already sent" issues. */
I tried several solutions, tried to make it work via plugin, nothing help.

How to change the logo of a child page on Wordpress

Header.php
<div class="site-branding">
<div class="container">
<?php
***if ( is_page('/category/fitness/') ) ?>{
<img src="<?php bloginfo('template_url'); ?> /assets/images/fitnesslogo.jpg"
width="100" height="100"/>
}***
<?php
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}
if ( is_front_page() && is_home() ) : ?>
<h1 class="site-title"><a href="<?php echo esc_url(
home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<?php else : ?>
<p class="site-title"><a href="<?php echo esc_url( home_url(
'/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
<?php
endif;
$description = get_bloginfo( 'description', 'display' );
if ( $description || is_customize_preview() ) : ?>
<p class="site-description"><?php echo $description; /*
WPCS: xss ok. */ ?></p>
<?php
endif; ?>
<?php do_action('boston_after_site_description'); ?>
</div>
</div><!-- .site-branding -->
The page slug is /category/fitness as the URL on the end of the page suggests when I go to the page it looks like it's not interpreting the img src, but is displaying '{}' tags that are around the img scr instead
You have:
***if ( is_page('/category/fitness/') ) ?>{
<img src="<?php bloginfo('template_url'); ?> /assets/images/fitnesslogo.jpg"
width="100" height="100"/>
}***
But it should be
if ( is_page('/category/fitness/') ) {
echo '<img src="'.bloginfo('template_url').'/assets/images/fitnesslogo.jpg" width="100" height="100"/>';
}
I'm not familiar with the Boston theme, but it looks like it's checking to see if a custom logo has been added and if so to use it. So, I would think the following would give you what you're looking for.
<?php if ( is_page('/category/fitness/') ) : ?>
<img src="<?php bloginfo('template_url'); ?>/assets/images/fitnesslogo.jpg" width="100" height="100"/>
<?php else : ?>
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}

Is there any actual way to pull in a featured image from a blog post into a div on another page template as a background image

I am trying to add a grid of blog posts to my homepage template. I have pulled in the content from 4 blog posts, now I just need to pull in the featured image as a background for each div.
Here is my current, half finished code, the background inline style isnt actually working right now, and I can't figure out why.
<?php /* Template Name: Home Content Template*/ ?>
<?php get_header(); ?>
<div class="row show-grid lrds-hm-grd-wrppr">
<div class="span2 lrds-hm-grd-bx lrds-hm-grd-bx-2" data-original-title="" title="" style="background url (<?php echo get_the_post_thumbnail_url($post_id1, 'full'); ?>) center center; background-size: cover; background-repeat: no-repeat;">
<?php
$post_id1 = 172;
$queried_post = get_post($post_id1);
?>
<h2><?php echo $queried_post->post_title; ?></h2>
<?php echo $queried_post->post_content; ?>
</div>
<div class="span2 lrds-hm-grd-bx lrds-hm-grd-bx-2" data-original-title="" title="" style="background url (<?php echo get_the_post_thumbnail_url($post_id2, 'full'); ?>) center center; background-size: cover; background-repeat: no-repeat;">
<?php
$post_id2 = 174;
$queried_post = get_post($post_id2);
?>
<h2><?php echo $queried_post->post_title; ?></h2>
<?php echo $queried_post->post_content; ?>
</div>
<div class="span3 lrds-hm-grd-bx lrds-hm-grd-bx-3" data-original-title="" title="" style="background url (<?php echo get_the_post_thumbnail_url($post_id3, 'full'); ?>) center center; background-size: cover; background-repeat: no-repeat;">
<?php
$post_id3 = 176;
$queried_post = get_post($post_id3);
?>
<h2><?php echo $queried_post->post_title; ?></h2>
<?php echo $queried_post->post_content; ?>
</div>
<div class="span4 lrds-hm-grd-bx lrds-hm-grd-bx-4" data-original-title="" title="" style="background url (<?php echo get_the_post_thumbnail_url($post_id4, 'full'); ?>) center center; background-size: cover; background-repeat: no-repeat;">
<?php
$post_id4 = 210;
$queried_post = get_post($post_id4);
?>
<h2><?php echo $queried_post->post_title; ?></h2>
<?php echo $queried_post->post_content; ?>
</div>
</div>
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-8">
<?php if(have_posts()) : ?>
<?php while(have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php the_title('<h2>','</h2>'); ?>
<?php the_content(); ?>
</div>
<?php
// tags anyone?
the_tags();
?>
<?php endwhile; ?>
<?php if (!is_singular()) : ?>
<div class="nav-previous alignleft"><?php next_posts_link( 'Older posts' ); ?></div>
<div class="nav-next alignright"><?php previous_posts_link( 'Newer posts' ); ?></div>
<?php endif; ?>
<?php else : ?>
<div class="alert alert-info">
<strong>No content in this loop</strong>
</div>
<?php endif; ?>
</div>
<div class="col-md-2">
<?php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar')) : // Sidebar name
?>
<?php
endif;
?>
</div>
</div>
<?php get_footer(); ?>
yes just pass it like this in all your
background url (<?php echo wp_get_attachment_url (get_post_thumbnail_id( $post_id($post_id)); ?>)
Here is an example of a working file with the background image being pulled in from the featured image of the same page, not a separate blog post (which is what I am currently trying to do on a different template)
'code'
<?php $title = trim(get_field("custom_headline"));
// check for custom title different from page name
if ($title == "") {
$title = Trim(get_the_title());
}
?>
<h2><?php echo $title; ?></h2>
<?php
global $related_du;
$rel = $related_du->show( get_the_ID(), true );
$boxTitle = array();
$boxContent = array();
$i = 0;
// Display the title of each related post
if( is_array( $rel ) && count( $rel ) > 0 ) {
foreach ( $rel as $r ) {
if ( is_object( $r ) ) {
if ($r->post_status != 'trash') {
//echo get_the_title( $r->ID ) . '<br />';
//echo get_post($post = $r->ID ) . '<br />';
$displayString = "";
$content_post = get_post($r->ID);
$boxTitle[$i] = $content_post->post_title;
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$boxContent[$i] = $content;
$i++;
}
}
}
}
?>
<div class="hero2box" style="background:URL(<?php the_post_thumbnail_url( 'full' ); ?>) center center; background-size: cover; background-repeat: no-repeat;">
<div class="col-sm-1"></div>
<div class="col-sm-5 tanLeft">
<h4><?php echo $boxTitle[0] ; ?></h4>
<hr class="red">
<?php echo $boxContent[0] ; ?>
</div>
<div class="col-sm-5 tanRight">
<h4><?php echo $boxTitle[1] ; ?></h4>
<hr class="red">
<?php echo $boxContent[1] ; ?>
</div>
<div class="col-sm-1"></div>
</div>
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-8">
<?php while(have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php the_content(); ?>
<?php //echo get_post_type(); ?>
</div>
<?php
// tags anyone?
the_tags();
?>
<?php endwhile; ?>
<?php if (!is_singular()) : ?>
<div class="nav-previous alignleft"><?php next_posts_link( 'Older posts' ); ?></div>
<div class="nav-next alignright"><?php previous_posts_link( 'Newer posts' ); ?></div>
<?php endif; ?>
<?php else : ?>
<div class="alert alert-info">
<strong>No content in this loop</strong>
</div>
<?php endif; ?>
</div>
<div class="col-md-2">
<?php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar')) : // Sidebar name
?>
<?php
endif;
?>
</div>
<?php
global $related;
$rel = $related->show( get_the_ID(), true );
// Display the title of each related post
if( is_array( $rel ) && count( $rel ) > 0 ) {
foreach ( $rel as $r ) {
if ( is_object( $r ) ) {
if ($r->post_status != 'trash') {
//echo get_the_title( $r->ID ) . '<br />';
//echo get_post($post = $r->ID ) . '<br />';
$displayString = "";
$content_post = get_post($r->ID);
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$displayString = $displayString . $content . "";
echo $displayString;
}
}
}
}
?>
'code'
Ok Solved! I had to be more simple, cuz I'm dumb sometimes. :P
<?php
$post_id1 = 172;
$queried_post = get_post($post_id1);
?>
<div class="row show-grid lrds-hm-grd-wrppr">
<div class="span2 lrds-hm-grd-bx lrds-hm-grd-bx-2" style="background:url(<?php echo wp_get_attachment_url(get_post_thumbnail_id( $post_id1)); ?>) ">
<h2><?php echo $queried_post->post_title; ?></h2>
<?php echo $queried_post->post_content; ?>
</div>

ACF repeater field custom image size output

I'm trying to output custom image size in my code:
<?php if(get_field('repeater-field-name')) { ?>
<?php foreach (get_field('repeater-field-name') as $row) :?>
<div class="item" onclick="location.href='<?php print $row['link'] ?>';" style="cursor: pointer;">
<div class="sisseviskaja-title"><h2><?php print $row['title'] ?></h2></div>
<div class="sisseviskaja-pilt"><img src="<?php print $row['image'] ?>" alt="" /></div>
</div>
<?php endforeach; ?>
<?php } ?>
I have tried ACF tutorial codes but i'd like to keep foreach loop that i have. I'm no PHP guru so i havent got any good ideas to implement it.
Can someone, please, help me?
Here's the way to do with ACF codes. This is using array for the image (which you need to do if you want to pull out the dimensions). I'm not sure exactly if it can be done the way you want to do it.
<?php if (have_rows('project_listings')){ ?>
<?php while (have_rows('project_listings')){ the_row();
$link = get_sub_field('link_field');
$title = get_sub_field('title_field');
$image = get_sub_field('image');
//additional vars
$size = 'full';
$width = $image['sizes'][ $size . '-width' ];
$height = $image['sizes'][ $size . '-height' ];
?>
<div class="item" onclick="location.href='<?php echo $link ?>';" style="cursor: pointer;">
<div class="sisseviskaja-title">
<h2><?php echo $title ?></h2>
</div>
<div class="sisseviskaja-pilt">
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>"/>
</div>
</div>
<?php }; ?>
<?php }; ?>
I do it like this:
<?php if( have_rows('field-name') ): ?>
<?php while( have_rows('field-name') ): the_row(); ?>
<?php
$image = get_sub_field('picture');
$size = 'thumbnail'; // (thumbnail, medium, large, full or custom size)
if( $image ) {
echo wp_get_attachment_image( $image, $size );
}
?>
<?php endwhile; ?>
<?php endif; ?>

Resources