Home › Forums › General Issues › llegal string offset
Hi i had a problem
i don’t know why because before my code works
this is my warning :
Warning: Illegal string offset 'sizes' in htdocs/wp-content/themes/sa/partials/grid.php on line 37
Warning: Illegal string offset 'medium_large' in htdocs/wp-content/themes/sa/partials/grid.php on line 37
Warning: Illegal string offset 'sizes' in htdocs/wp-content/themes/sa/partials/grid.php on line 38
Warning: Illegal string offset 'medium_large-width' in htdocs/wp-content/themes/sa/partials/grid.php on line 38
Warning: Illegal string offset 'sizes' in htdocs/wp-content/themes/sa/partials/grid.php on line 39
Warning: Illegal string offset 'medium_large-height' in htdocs/wp-content/themes/sa/partials/grid.php on line 39
Warning: Illegal string offset 'sizes' in htdocs/wp-content/themes/sa/partials/grid.php on line 40
Warning: Illegal string offset 'title' in htdocs/wp-content/themes/sa/partials/grid.php on line 40
and this is my code
<?php
/* GET PROJECT CATEGORIES
* not for grid articles (= home)
*/
if(!is_front_page()) {
$project_categories = get_terms( array(
'taxonomy' => 'project_category',
'hide_empty' => false,
));
?>
<div class="nav-project-category">
<button class="button-nav-project-category button button-small">Catégories <i class="icon icon-arrow-right"></i></button>
<ul class="nav-project-category-list hidden-md hidden-lg">
<?php
foreach ($project_categories as $project_category) {
echo '<li><a href="' . URL . $project_category->taxonomy . '/' . $project_category->slug . '" class="' . (get_queried_object()->term_id == $project_category->term_id ? 'is-active' : '') . '">' . $project_category->name . '</a></li>';
}
?>
</ul>
</div>
<?php
}
// GRID LOOP
echo '<div class="grid grid-' . $page_title . '">';
if(count($items) > 0) {
while ($items->have_posts()) : $items->the_post();
$item_id = get_the_ID();
$item_url = get_the_permalink($item_id);
$item_title = get_the_title();
$item_short_description = ($page_title == 'home' ? get_field('description_courte', $item_id) : get_field('lieu', $item_id));
$item_img = get_field('image1', $item_id);
$item_img_thumbnail = $item_img['sizes']['medium_large'];
$item_img_thumbnail_width = $item_img['sizes']['medium_large-width'];
$item_img_thumbnail_height = $item_img['sizes']['medium_large-height'];
$item_img_thumbnail_alt = $item_img['sizes']['title'];
echo '<div class="grid-item">
<div class="item-content">
<a href="' . $item_url . '" class="item-img">
<span class="mask"></span>
<span class="more"><i class="icon icon-plus"></i></span>
<img src="' . $item_img_thumbnail . '" alt="' . $item_img_thumbnail_alt . '" width="' . $item_img_thumbnail_width . '" height="' . $item_img_thumbnail_height . '" />
</a>
<a href="' . $item_url . '" class="item-text">
<h3 class="item-title top-separated">' . $item_title . '</h3>
<span class="item-description">' . $item_short_description . '</span>
' . ($page_title == 'home' ? '<span class="item-more">+</span>' : '') . '
</a>
</div>
</div>';
endwhile;
wp_reset_query();
}
else
echo '<p>Aucun projet</p>';
echo '</div>';
?>
can you help me ?
this is line where the warning are
$item_img_thumbnail_width = $item_img['sizes']['medium_large-width'];
$item_img_thumbnail_height = $item_img['sizes']['medium_large-height'];
$item_img_thumbnail_alt = $item_img['sizes']['title'];
The topic ‘llegal string offset’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.